From 5e9b6e761f2d47a9edcfdbdcc9bdb6514a6036b1 Mon Sep 17 00:00:00 2001 From: eeckert Date: Fri, 15 Sep 2023 14:07:21 -0600 Subject: [PATCH] stupid code formatter --- Generate Egnyte Export.sql | 19 ++++++++++--------- Get-ProjectFolders.ps1 | 10 +++++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Generate Egnyte Export.sql b/Generate Egnyte Export.sql index 451a636..b7f198c 100644 --- a/Generate Egnyte Export.sql +++ b/Generate Egnyte Export.sql @@ -1,12 +1,14 @@ -- Generate Non-Duplicated PARENT FOLDER List DROP TABLE DataInventory; CREATE TABLE DataInventory AS -Select * from ( - SELECT SERVER,Parent, - REPLACE( +Select * +from ( + SELECT SERVER, Parent, - "X:\"," \\mpe.ca\datadrive\") AS UNCPath, - REPLACE(REPLACE(Parent,("X:\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath, + REPLACE( + Parent, + "X:\","\\mpe.ca\datadrive\") AS UNCPath, + REPLACE(REPLACE(Parent,("X:\" || Server),"/Shared/N-Data")," \ "," / ") AS EgnytePath, sum(FileCount), Sum(FileSize), 'Parent' as Source from FolderData Where Parent != ( SELECT Parent FROM DuplicateList @@ -15,8 +17,8 @@ GROUP by UNCPath ) UNION SELECT SERVER, Parent, - REPLACE(PATH," X:\","\\mpe.ca\datadrive\") AS UNCPath, - REPLACE(REPLACE(PATH,("X:\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath, + REPLACE(PATH,"X:\","\\mpe.ca\datadrive\") AS UNCPath, + REPLACE(REPLACE(PATH,("X:\" || Server),"/Shared/N-Data")," \ "," / ") AS EgnytePath, FileCount, FileSize, 'Project' as Source from FolderData Where FolderData.Project NOT in ( SELECT A.Project FROM DuplicateList as A) @@ -31,5 +33,4 @@ where Parent in ( group by Parent HAVING count(*) > 1 ) -and Source = 'Project'; - +and Source = 'Project'; \ No newline at end of file diff --git a/Get-ProjectFolders.ps1 b/Get-ProjectFolders.ps1 index 6d9cefb..ee26d12 100644 --- a/Get-ProjectFolders.ps1 +++ b/Get-ProjectFolders.ps1 @@ -101,7 +101,7 @@ $OfficeList | ForEach-Object -parallel { } elseif ($result.Length -ge 5) { $Server = $_.FullName.Substring(1, 4) -replace (':|\\', '') - $Path = $_.FullName + $Path = $_.FullName.Replace("'", "''") #SQL Formatted Path $projectnumber = $result.tostring() $DBConnect = New-SqliteConnection -DataSource $PathToDB_Copy $Query = "Select Project FROM FolderData where Project = '$ProjectNumber' AND Server = '$Server' AND Path = '$Path';" @@ -119,7 +119,7 @@ $OfficeList | ForEach-Object -parallel { $result3 = [Regex]::Matches($_.FullName, "^(.*[\\\/])") # This gets everything up the last slash, thus the "parent" $FolderPath_Data = Get-ChildItem -Path $_.FullName -File -Depth 50 -Recurse - $folder_Parent = $result3.value + $folder_Parent = $result3.value.replace("'", "''") #SQL Formatting $folder_FileSize = ($FolderPath_Data | Measure -sum Length).sum / 1024 / 1024 / 1024 $folder_FileCount = ($FolderPath_Data | measure).Count $folder_LastWrite = ($FolderPath_Data | measure LastWriteTime -Maximum).Maximum @@ -134,8 +134,8 @@ $OfficeList | ForEach-Object -parallel { $out = [PSCustomObject]@{ Server = $Server Project = $ProjectNumber.ToString() - Parent = "'$folder_Parent'" - Path = "'$Path'" + Parent = $folder_Parent + Path = $Path FileCount = $folder_FileCount FileSize = $folder_FileSize FileLastWrite = $folder_LastWrite @@ -232,7 +232,7 @@ catch { } $SQLFile_to_Run = $PSScriptRoot + '\Generate Egnyte Export.sql' Invoke-SqliteQuery -DataSource $PathToDB -InputFile $SQLFile_to_Run -$EgnyteExport = Invoke-SqliteQuery -DataSource $PathToDB -Query "Select * from DataInventory" +$EgnyteExport = Invoke-SqliteQuery -DataSource $PathToDB -Query "Select Server,UNCPath,EgnytePath,FileCount,FileSize,Source from DataInventory" if ($EgnyteExport) {