Blue Iris Clips and Files - Disk Usage Utility

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,133
Reaction score
1,242
Location
SF Bay Area
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:

Philip Gonzales

Getting comfortable
Joined
Sep 20, 2017
Messages
697
Reaction score
551
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
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,133
Reaction score
1,242
Location
SF Bay Area
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:

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,133
Reaction score
1,242
Location
SF Bay Area
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:

Philip Gonzales

Getting comfortable
Joined
Sep 20, 2017
Messages
697
Reaction score
551
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
 

Philip Gonzales

Getting comfortable
Joined
Sep 20, 2017
Messages
697
Reaction score
551
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
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,133
Reaction score
1,242
Location
SF Bay Area
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.
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,133
Reaction score
1,242
Location
SF Bay Area
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:

scoob8000

Getting the hang of it
Joined
Dec 28, 2018
Messages
101
Reaction score
48
Location
PA
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
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
1,133
Reaction score
1,242
Location
SF Bay Area
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:

scoob8000

Getting the hang of it
Joined
Dec 28, 2018
Messages
101
Reaction score
48
Location
PA
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! :)
 
Top