diff --git a/Get-ProjectFolders.ps1 b/Get-ProjectFolders.ps1 index 783cf94..f168bfb 100644 --- a/Get-ProjectFolders.ps1 +++ b/Get-ProjectFolders.ps1 @@ -13,7 +13,7 @@ X:\CG | ProjectNumber | FullPath | filecount #> -$Refresh = $false #refresh all data - causes the DB to be wiped clean and all file folders to be re-analyzed. +$Refresh = $true #refresh all data - causes the DB to be wiped clean and all file folders to be re-analyzed. $PathToDB = "M:\IT\Egnyte\DuplicateFiles\WorkingRun\Dedupe.SQLite" @@ -22,8 +22,19 @@ $BaseDrive = 'X:\' $ProjectRegex = '^X:\\[A-Z]{2}\W\d{2}\\\d{2}' $OfficeList = Get-ChildItem -Path $BaseDrive -Directory -Depth 0 +if ($Refresh) { + # Reset the DB, start fresh + $DBConnect = New-SqliteConnection -DataSource $PathToDB + $ClearQuery = 'DELETE FROM FolderData;' + Invoke-SqliteQuery -DataSource $PathToDB -Query $ClearQuery + + $DBConnect.close() +} + + + + $OfficeList | ForEach-Object -parallel { - $Refesh_Copy_Main = $USING:Refresh $PathToDB_Copy_Main = $USING:PathToDB $ServerProgress = @{ ID = 1 @@ -42,7 +53,6 @@ $OfficeList | ForEach-Object -parallel { # We need to get a file count for each "last" folder - IE, 001 in the example 1234-567-001. $ProjectFolders | ForEach-Object -ThrottleLimit 15 -Parallel { - $Refresh_Thread = $USING:Refresh_Copy_Main $PathToDB_Copy = $USING:PathToDB_Copy_Main $JobID = Get-Random @@ -54,16 +64,6 @@ $OfficeList | ForEach-Object -parallel { # Write-Progress @CurentLoopProgress - if ($Refresh_Thread) { - # Reset the DB, start fresh - $DBConnect = New-SqliteConnection -DataSource $PathToDB_Copy - $ClearQuery = 'DELETE FROM FolderData;' - Invoke-SqliteQuery -DataSource $PathToDB_Copy -Query $ClearQuery - - - } - - $projectNumber = '' # thank you ChatGPT