Blue Iris Clips and Files - Disk Usage Utility

Maybe I missed a really simple step here but I downloaded the V5 version of the script, but every time I ran it, I got the following error.

ERR/failed to load user settings file 'BI_clip_usage_user_settings.ps1'
Tip: try executing it directly to confirm it exists and reveal syntax errors


I validated both scripts existed in C:\scripts.

I ended up having to change line 868 to the explicit full path of the settings .ps1 file. Then it worked fine.
$user_settings_filename = 'C:\Scripts\BI_clip_usage_user_settings.ps1'

When line 868 was set as below
$user_settings_filename = $ScriptName.Replace(".ps1", "_user_settings.ps1")

The output of Write-Host $user_settings_filename was
BI_clip_usage_user_settings.ps1
Thanks for reporting this.

Questions:
1. Please confirm that the script is working for you with your code tweak?
2. What version of PowerShell are you running? To get the version, type this in your console: $PSVersionTable
3. Is folder C:\Scripts on your server's Environment path?
 
Last edited:
Aha! The problem was with question 3. Apologies, I wasn't aware that this was required. I even tested with explicitly changing directory in PowerShell ISE to C:\Scripts before running.

TBH, I just created the directory yesterday after finding your script. It was late and I should have been sleeping but instead was trying to get the script to work for me. :D

I'll still answer the questions below in case it is helpful in any way.

1. Please confirm that the script is working for you with your code tweak?

Yes, it works fine with the tweak. Tested several different ways. Launching with PowerShell, launching from PowerShell ISE, adding -SortColNo argument, etc.

2. What version of PowerShell are you running? To get the version, type this in your console: $PSVersionTable


Name Value
---- -----
PSVersion 5.1.20348.2031
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.20348.2031
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

3. Is folder C:\Scripts on your server's Environment path?

Negative, adding the environment variable of C:\Scripts to the Path variable solved the issue. Even tested removing it and confirmed this is what caused the script to error out for me.

Again, apologies from my side.

Thanks Jaydeel for the awesome script and for the assist!

Regards,

Philip
 
  • Like
Reactions: jaydeel
Aha! The problem was with question 3. Apologies, I wasn't aware that this was required. I even tested with explicitly changing directory in PowerShell ISE to C:\Scripts before running.
I usually note this requirement, but checking post #1 I see I forgot this time.

It just dawned on me that the script should self-check for this requirement. I'll add this in the next update.
 
Last edited:
Script updated to V6. see post #1 to download the file

Please note the BREAKING CHANGE
see changelog item 1 below

Once again, you will need to edit the user settings file.

Changelog:
  1. BREAKING CHANGE: script now gets all Blue Iris storage folder paths directly from the Windows Registry
  2. CHANGE: eliminated user settings $sourceN & $alerts_folder_path
  3. CHANGE: added optional user setting $show_folderN; $false prevents analysis of folder path #N
  4. CHANGE: the order in which Blue Iris folders are displayed is no longer customizable
  5. NEW: added optional user setting $override_folderN; for testing; replaces folder path(s) extracted from the Registry
  6. NEW: script now self-checks existence of its own path in the Windows Environment System Path variable

The following screenshot shows the new USER SETTINGS.
V6.user_settings_1.png
 
Last edited:
  • Like
Reactions: Philip Gonzales
Sweet, purposely removed the environment variable and got the below error on execution.

ERR/this script's path 'C:\Scripts' does not exist in the Environment System Path variable.

I took it a step further and asked ChatGPT to fix it up and it seems to have done an OK job to me (I am no developer obviously).

Code:
# CHECK IF SCRIPT'S PATH IS IN ENVIRONMENT 'SYSTEM PATH' VARIABLE

$EnvPath = [System.Environment]::GetEnvironmentVariable('Path', 'Machine')

if ($EnvPath -ne $null) {
    $PathList = $EnvPath -split ';'
    
    if (-not $PathList.Contains($ScriptPath)) {
        $PathList += $ScriptPath
        $NewEnvPath = $PathList -join ';'
        
        [System.Environment]::SetEnvironmentVariable('Path', $NewEnvPath, 'Machine')
        
        Write-Warning "Added this script's path '$ScriptPath' to the Environment Path"
    }
} else {
    Write-Warning "Unable to inspect Environment variable; be sure the script's path is in the Environment Path"
}

# for debugging
#Write-Host ("EnvPath = " + (($EnvPath -Split ';') | ConvertTo-Json))

1699318472786.png
 
Ah actually I am a dummy. I see the duplicates above now. Failed QA!
That's an easy fix, just asked ChatGPT to fix it, this time foreal.

Apologies if I come off as rude. I dabble a little in the copy and paste so I think I know a thing or two. I know just enough to be dangerous. Do with this information what you whish. Just thought it was fun to try (although I am def. cheating a ton using ChatGPT).

Code:
# CHECK IF SCRIPT'S PATH IS IN ENVIRONMENT 'SYSTEM PATH' VARIABLE

$EnvPath = [System.Environment]::GetEnvironmentVariable('Path', 'Machine')

if ($EnvPath -ne $null) {
    $PathList = $EnvPath -split ';'

    # Check for duplicates (case-insensitive)
    $isDuplicate = $false
    foreach ($path in $PathList) {
        if ($ScriptPath -ieq $path) {
            $isDuplicate = $true
            break
        }
    }

    if (-not $isDuplicate) {
        $PathList += $ScriptPath
        $NewEnvPath = $PathList -join ';'

        [System.Environment]::SetEnvironmentVariable('Path', $NewEnvPath, 'Machine')

        Write-Warning "Added the script's path '$ScriptPath' to the Environment Path"
    } else {
        Write-Host "The script's path '$ScriptPath' already exists in the Environment Path"
    }
} else {
    Write-Warning "Unable to inspect Environment variable; be sure the script's path is in the Environment Path"
}

# for debugging
#Write-Host ("EnvPath = " + (($EnvPath -Split ';') | ConvertTo-Json))

1699332986844.png
 
No problem.

I did not mention that I explored auto-fixing the missing entry in the Environment Path. Like you, I observed the same issue (duplicate Path variable entries). Rather than debug the issue, I purposely decided leave it to the user to fix the Path entry themselves. I felt this was a better solution than potentially annoying the user if the script messed up their system configuration.
 
  • Like
Reactions: Philip Gonzales
BTW, here’s a utility you can use to inspect and repair Environment variables (like ‘Path’).

It has a feature that will remove duplicate entries in a variable (so you don’t have to do this manually).

Note: You will probably want to run it as an Administrator.
 
Last edited:
  • Like
Reactions: Philip Gonzales
Got a little issue with v6. I'm only getting output for my main New folder and nothing for Aux 1. I have storage set to false since I don't use it.
Code:
$show_folder1 = $true     # 'New' folder,     like 'D:\BlueIris\New'
$show_folder2 = $true     # 'Aux1' folder,    like 'E:\BlueIris\New'
$show_folder3 = $false     # 'Alerts' folder, like 'D:\BlueIris\Alerts
$show_folder4 = $false    # 'Storage' folder,    like 'D:\BlueIris\storage'
$show_folder5 = $false    # 'Aux2' folder,    like 'D:\BlueIris\Aux2'
$show_folder6 = $false    # 'Aux3' folder,    like 'D:\BlueIris\Aux3'

Code:
C:\Users\camera>powershell c:\scripts\BI_clip_usage.ps1
=================================================================================
Blue Iris Clips & Files - disk usage by camera AND file type (bvr, mp4, jpg, dat)
---------------------------------------------------------------------------------
Args:  -SortColNo ... sort output tables on specified column number (1-N)
       -Ascending ... sort column in ascending order (default is descending)
       -DefFnameFormat ... override USER SETTING $default_filename_format_flg
---------------------------------------------------------------------------------
Reading directories and binning file info...

NOTE: per your USER SETTINGS, you ARE using the default filename format
(this format is specified in each camera's Camera settings > Recording tab)

/////////////////////////////////////////
Folder: D:\blueiris\new

Camera        Type Count TotalGB AvgGB MaxGB #Days Oldest              Newest
------        ---- ----- ------- ----- ----- ----- ------              ------
TOTAL         bvr    456 1026.87  2.25 25.03       2023-11-03T08:00:00 2023-11-09T01:35:26
ShedCam       bvr     17  252.38 14.85 22.30     7 2023-11-03T08:00:00 2023-11-09T01:35:26
AtticFront    bvr      9  103.81 11.53 25.03     6 2023-11-03T20:00:00 2023-11-09T01:35:26
HillDriveway  bvr      8   95.96 11.99 20.00     5 2023-11-03T20:00:00 2023-11-09T01:35:26
AtticRear     bvr      9   95.41 10.60 20.51     6 2023-11-03T20:00:00 2023-11-09T01:35:26
Deck          bvr      9   88.55  9.84 21.06     5 2023-11-03T20:00:00 2023-11-09T01:35:26
driveway      bvr      9   76.25  8.47 20.20     6 2023-11-03T20:00:00 2023-11-09T01:35:26
RDriveway     bvr      9   72.15  8.02 14.29     5 2023-11-03T20:00:00 2023-11-09T01:35:26
LDriveway     bvr      9   64.13  7.13 14.00     7 2023-11-03T20:00:00 2023-11-09T01:35:26
UpGarL        bvr      8   63.56  7.94 10.78     6 2023-11-03T20:00:00 2023-11-09T01:35:26
HouseRear     bvr      9   57.77  6.42  9.94     6 2023-11-03T20:00:00 2023-11-09T01:35:26
shedcam2      bvr     11   16.77  1.52  2.49     5 2023-11-05T09:19:13 2023-11-09T01:35:26
frontdoorbell bvr      5   16.19  3.24  5.12     4 2023-11-05T19:00:00 2023-11-09T01:35:26
Garage        bvr      5   12.86  2.57  3.80     4 2023-11-05T19:00:00 2023-11-09T01:35:26
GarageG7      bvr      5    9.19  1.84  2.62     4 2023-11-05T19:00:00 2023-11-09T01:35:26
Dogden        bvr    334    1.89  0.01  0.01     5 2023-11-05T10:55:47 2023-11-09T00:56:37


Note: The table above has been saved to 'c:\scripts\output_new_bvr_2023-11-09_063526.csv'

/////////////////////////////////////////
Folder: D:\blueiris\storage

/////////////////////////////////////////
Archived CSV Files Maintenance Summary:
Count of archived CSV files matching 'c:\scripts\*_20*.csv' = 36
Count of archived CSV files pruned (age >= 365 days) = 0
 
Got a little issue with v6. I'm only getting output for my main New folder and nothing for Aux 1. I have storage set to false since I don't use it.
Code:
$show_folder1 = $true     # 'New' folder,     like 'D:\BlueIris\New'
$show_folder2 = $true     # 'Aux1' folder,    like 'E:\BlueIris\New'
$show_folder3 = $false     # 'Alerts' folder, like 'D:\BlueIris\Alerts
$show_folder4 = $false    # 'Storage' folder,    like 'D:\BlueIris\storage'
$show_folder5 = $false    # 'Aux2' folder,    like 'D:\BlueIris\Aux2'
$show_folder6 = $false    # 'Aux3' folder,    like 'D:\BlueIris\Aux3'

Code:
C:\Users\camera>powershell c:\scripts\BI_clip_usage.ps1
=================================================================================
Blue Iris Clips & Files - disk usage by camera AND file type (bvr, mp4, jpg, dat)
---------------------------------------------------------------------------------
Args:  -SortColNo ... sort output tables on specified column number (1-N)
       -Ascending ... sort column in ascending order (default is descending)
       -DefFnameFormat ... override USER SETTING $default_filename_format_flg
---------------------------------------------------------------------------------
Reading directories and binning file info...

NOTE: per your USER SETTINGS, you ARE using the default filename format
(this format is specified in each camera's Camera settings > Recording tab)

/
Folder: D:\blueiris\new

Camera        Type Count TotalGB AvgGB MaxGB #Days Oldest              Newest
------        ---- ----- ------- ----- ----- ----- ------              ------
TOTAL         bvr    456 1026.87  2.25 25.03       2023-11-03T08:00:00 2023-11-09T01:35:26
ShedCam       bvr     17  252.38 14.85 22.30     7 2023-11-03T08:00:00 2023-11-09T01:35:26
AtticFront    bvr      9  103.81 11.53 25.03     6 2023-11-03T20:00:00 2023-11-09T01:35:26
HillDriveway  bvr      8   95.96 11.99 20.00     5 2023-11-03T20:00:00 2023-11-09T01:35:26
AtticRear     bvr      9   95.41 10.60 20.51     6 2023-11-03T20:00:00 2023-11-09T01:35:26
Deck          bvr      9   88.55  9.84 21.06     5 2023-11-03T20:00:00 2023-11-09T01:35:26
driveway      bvr      9   76.25  8.47 20.20     6 2023-11-03T20:00:00 2023-11-09T01:35:26
RDriveway     bvr      9   72.15  8.02 14.29     5 2023-11-03T20:00:00 2023-11-09T01:35:26
LDriveway     bvr      9   64.13  7.13 14.00     7 2023-11-03T20:00:00 2023-11-09T01:35:26
UpGarL        bvr      8   63.56  7.94 10.78     6 2023-11-03T20:00:00 2023-11-09T01:35:26
HouseRear     bvr      9   57.77  6.42  9.94     6 2023-11-03T20:00:00 2023-11-09T01:35:26
shedcam2      bvr     11   16.77  1.52  2.49     5 2023-11-05T09:19:13 2023-11-09T01:35:26
frontdoorbell bvr      5   16.19  3.24  5.12     4 2023-11-05T19:00:00 2023-11-09T01:35:26
Garage        bvr      5   12.86  2.57  3.80     4 2023-11-05T19:00:00 2023-11-09T01:35:26
GarageG7      bvr      5    9.19  1.84  2.62     4 2023-11-05T19:00:00 2023-11-09T01:35:26
Dogden        bvr    334    1.89  0.01  0.01     5 2023-11-05T10:55:47 2023-11-09T00:56:37


Note: The table above has been saved to 'c:\scripts\output_new_bvr_2023-11-09_063526.csv'

/
Folder: D:\blueiris\storage

/
Archived CSV Files Maintenance Summary:
Count of archived CSV files matching 'c:\scripts\*_20*.csv' = 36
Count of archived CSV files pruned (age >= 365 days) = 0
The changelog notes that the folder order is no longer customizable. $show_folder1 to $show_folder3 must be New, Storage, Alerts in that order; likewise,$show_folder4 to $show_folder16 must be Aux1-13.

Try $true, $false, $false, $true for $show_folder1 to $show_folder4.
 
Last edited:
  • Like
Reactions: scoob8000
The changelog notes that the folder order is no longer customizable. $show_folder1 to $show_folder3 must be New, Storage, Alerts in that order; likewise,$show_folder4 to $show_folder16 must be Aux1-13.

Try $true, $false, $false, $true for $show_folder1 to $show_folder4.

Hahah Fixed. Read the directions newb! :)
 
If you change line 938 thusly:
. $ScriptPath\$user_settings_filename

then the script directory does not have to be in the path. Lines 117 through 132 no longer needed.
 
If you change line 938 thusly:
. $ScriptPath\$user_settings_filename

then the script directory does not have to be in the path. Lines 117 through 132 no longer needed.
The change is a good idea. I'll make the change in V7.
Of course, it works only if the Console command includes the full path.

I'll also change the current fatal error to a 'Heads-up' warning.
 
Script updated to V7. see post #1 to download the file.

Please note the BREAKING CHANGE
see changelog item 1 below

Once again, you will need to edit the user settings file.

Changelog:
  1. BREAKING CHANGE: script now requires a JSON call to the Blue Iris server; additional user-settings required.
  2. NEW: added argument -ShowFolders to display all Blue Iris Storage folders & highlight those that will be displayed
  3. NEW: script now self-checks if ANY camera is using a non-default filename format (Camera settings > Record tab);
    Note: this feature is skipped if user setting default_filename_format_flg is detected (regardless of its value)
  4. NEW: added argument -Help; usage guide no longer displayed by default
  5. NEW: added heads-up checking for unsupported commandline arguments
  6. CHANGE: removed 'T' from 'Oldest' and 'Newest' date column values; makes table easier to read (less cluttered)
  7. CHANGE: changed fatal error message to non-fatal warning when script's path not in Environment Path variable
  8. FIXED: prepended script's path when importing user settings file; avoids file not in path error (thanks M Hotchin)
  9. FIXED: fixed bug in variable $bi_folders declaration ('Aux 3e')
  10. FIXED: fixed handling of 'Invalid session' in function BIJsonCall()

Updated usage guide
V7_usage_guide.png


Output from new argument -ShowFolder
V7_screenshot_1.png


Output when script detects the usage of a a non-default filename format (any camera)
V7_screenshot_2.png


Tweaked format of date columns ('Oldest', 'Newest')
V7_screenshot_3.png
 
Last edited:
Of course, it works only if the Console command includes the full path.

I'll also change the current fatal error to a 'Heads-up' warning.

In my opinion, even the warning is un-needed. The script now works like any other command - just execute the name if it's in the path, otherwise you need to call it by full pathname. This is the expected behaviour on Windows, there's no need to inform people that the script isn't in the path.
 
I added the check because I've received more than few inquiries from Inexperienced users.

Feel free to edit the code to suit yourself.
 
You say you can use the settings file from V6, but I get the following error:
ERR/user setting '$bi_webserver' is missing

Look like web server information is now required for the script to run. I'd say make it optional, and just skip whatever part of the script needs that information if not set.
 
You say you can use the settings file from V6, but I get the following error:
ERR/user setting '$bi_webserver' is missing

Look like web server information is now required for the script to run. I'd say make it optional, and just skip whatever part of the script needs that information if not set.
My bad. I was rushing and compared the wrong user-setting files. I'll fix the post.

The new functionality requires a JSON call to the server.
The option is to use V6 if you don't want the new functionality.
 
Changing two lines as follows:
913 - :
if ($cur_ary_cnt -gt 0 -and $Days -ne 0) {

2722:
if ($timestamp_output_csv_files_flg -and $archive_lifetime_days -ne 0) {

allows the option $archive_lifetime_days to be set to negative numbers. ANY negative number will prune ALL the CSV files. Other values behave the same as before.

I don't need history of usage, this cleans up the CSV files created for the report.