FileServerDedupe/Generate Egnyte Export.sql

36 lines
994 B
MySQL
Raw Normal View History

2023-09-14 15:29:46 -06:00
-- Generate Non-Duplicated PARENT FOLDER List
DROP TABLE DataInventory;
CREATE TABLE DataInventory AS
2023-09-15 14:07:21 -06:00
Select *
from (
SELECT SERVER,
2023-09-15 13:04:44 -06:00
Parent,
2023-09-15 14:07:21 -06:00
REPLACE(
Parent,
"X:\","\\mpe.ca\datadrive\") AS UNCPath,
2023-09-15 14:18:19 -06:00
REPLACE(REPLACE(Parent,("X:\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath,
sum(FileCount) as FileCount, Sum(FileSize) as FileSize, 'Parent' as Source from FolderData
2023-09-15 13:04:44 -06:00
Where Parent != (
SELECT Parent FROM DuplicateList
)
GROUP by UNCPath
2023-09-14 15:29:46 -06:00
)
UNION
2023-09-15 13:04:44 -06:00
SELECT SERVER, Parent,
2023-09-15 14:07:21 -06:00
REPLACE(PATH,"X:\","\\mpe.ca\datadrive\") AS UNCPath,
2023-09-15 14:18:19 -06:00
REPLACE(REPLACE(PATH,("X:\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath,
2023-09-15 13:04:44 -06:00
FileCount, FileSize, 'Project' as Source from FolderData
Where FolderData.Project NOT in (
SELECT A.Project FROM DuplicateList as A)
AND FolderData.Parent in (
Select B.Parent FROM DuplicateList as B
);
delete FROM DataInventory
where Parent in (
select Parent from DataInventory
group by Parent
HAVING count(*) > 1
)
2023-09-15 14:07:21 -06:00
and Source = 'Project';