stupid code formatter

This commit is contained in:
Erik Eckert 2023-09-15 14:07:21 -06:00
parent 56afe487cc
commit 5e9b6e761f
2 changed files with 15 additions and 14 deletions

View File

@ -1,12 +1,14 @@
-- Generate Non-Duplicated PARENT FOLDER List -- Generate Non-Duplicated PARENT FOLDER List
DROP TABLE DataInventory; DROP TABLE DataInventory;
CREATE TABLE DataInventory AS CREATE TABLE DataInventory AS
Select * from ( Select *
SELECT SERVER,Parent, from (
REPLACE( SELECT SERVER,
Parent, Parent,
"X:\"," \\mpe.ca\datadrive\") AS UNCPath, REPLACE(
REPLACE(REPLACE(Parent,("X:\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath, 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 sum(FileCount), Sum(FileSize), 'Parent' as Source from FolderData
Where Parent != ( Where Parent != (
SELECT Parent FROM DuplicateList SELECT Parent FROM DuplicateList
@ -15,8 +17,8 @@ GROUP by UNCPath
) )
UNION UNION
SELECT SERVER, Parent, SELECT SERVER, Parent,
REPLACE(PATH," X:\","\\mpe.ca\datadrive\") AS UNCPath, REPLACE(PATH,"X:\","\\mpe.ca\datadrive\") AS UNCPath,
REPLACE(REPLACE(PATH,("X:\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath, REPLACE(REPLACE(PATH,("X:\" || Server),"/Shared/N-Data")," \ "," / ") AS EgnytePath,
FileCount, FileSize, 'Project' as Source from FolderData FileCount, FileSize, 'Project' as Source from FolderData
Where FolderData.Project NOT in ( Where FolderData.Project NOT in (
SELECT A.Project FROM DuplicateList as A) SELECT A.Project FROM DuplicateList as A)
@ -31,5 +33,4 @@ where Parent in (
group by Parent group by Parent
HAVING count(*) > 1 HAVING count(*) > 1
) )
and Source = 'Project'; and Source = 'Project';

View File

@ -101,7 +101,7 @@ $OfficeList | ForEach-Object -parallel {
} }
elseif ($result.Length -ge 5) { elseif ($result.Length -ge 5) {
$Server = $_.FullName.Substring(1, 4) -replace (':|\\', '') $Server = $_.FullName.Substring(1, 4) -replace (':|\\', '')
$Path = $_.FullName $Path = $_.FullName.Replace("'", "''") #SQL Formatted Path
$projectnumber = $result.tostring() $projectnumber = $result.tostring()
$DBConnect = New-SqliteConnection -DataSource $PathToDB_Copy $DBConnect = New-SqliteConnection -DataSource $PathToDB_Copy
$Query = "Select Project FROM FolderData where Project = '$ProjectNumber' AND Server = '$Server' AND Path = '$Path';" $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" $result3 = [Regex]::Matches($_.FullName, "^(.*[\\\/])") # This gets everything up the last slash, thus the "parent"
$FolderPath_Data = Get-ChildItem -Path $_.FullName -File -Depth 50 -Recurse $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_FileSize = ($FolderPath_Data | Measure -sum Length).sum / 1024 / 1024 / 1024
$folder_FileCount = ($FolderPath_Data | measure).Count $folder_FileCount = ($FolderPath_Data | measure).Count
$folder_LastWrite = ($FolderPath_Data | measure LastWriteTime -Maximum).Maximum $folder_LastWrite = ($FolderPath_Data | measure LastWriteTime -Maximum).Maximum
@ -134,8 +134,8 @@ $OfficeList | ForEach-Object -parallel {
$out = [PSCustomObject]@{ $out = [PSCustomObject]@{
Server = $Server Server = $Server
Project = $ProjectNumber.ToString() Project = $ProjectNumber.ToString()
Parent = "'$folder_Parent'" Parent = $folder_Parent
Path = "'$Path'" Path = $Path
FileCount = $folder_FileCount FileCount = $folder_FileCount
FileSize = $folder_FileSize FileSize = $folder_FileSize
FileLastWrite = $folder_LastWrite FileLastWrite = $folder_LastWrite
@ -232,7 +232,7 @@ catch {
} }
$SQLFile_to_Run = $PSScriptRoot + '\Generate Egnyte Export.sql' $SQLFile_to_Run = $PSScriptRoot + '\Generate Egnyte Export.sql'
Invoke-SqliteQuery -DataSource $PathToDB -InputFile $SQLFile_to_Run 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) { if ($EgnyteExport) {