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
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';

View File

@ -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) {