Archiving files and folders, deleting empty folders in the process
Hi, i'm looking for a all-in-one solution for archiving old files and folders in my fileserver (macmini)
On the Macmini i'm sharing two drives; "Fileserver" and "Archive"
The fileserver has a lot of files on it (nicely sorted in many folders and subfolders)
And what i want to do is the following:
I'd like to create several folders on the Fileserver called "_Archive"
For example: Fileserver/A/Aardvark/Projects/_Archive/
And move old folders and files in that folder to archive them.
Now the tricky part:
I would like to run an app or script (on the macmini) to regularly check the entire drive 'fileserver' for all folders named "_archive" and MOVE (not copy) the contents of that folder to the other drive "Archive"
While keeping its original path (only the contents of the folder, not the folder itself).
If there are any empty folders in the _Archive folder they should be deleted in the process.
(including folders with only hidden files).
If possible: remove "_Archive" from the new path. In this example: Archive/A/Aardvark/Projects/
before:
fileserver/A/Aardvark/Projects/_Archive/000Job/file.txt
after:
archive/A/Aardvark/Projects/000Job/file.txt
This way i want keep the server nice and clean while maintaining an archive of old projects.
(i'll set the Archive share to 'read only' to prevent unintentional deletions)
I've tried to script it myself, but that didn't work out well.
I also tried several third-party apps but none of them worked to satisfaction.
Some problems i encountered:
-filtering to only process the contents of the found _Archive folders.
-creating folders on the Archive drive with the same path, and especially the merging with existing folders
-deletions of files that were NOT copied (yikes)
How would you approach this? with a third-party app (which?) or with automator/applescript?
It should run without user-intervention.
Bonuspoints of there is a way to automatically create a alias to the archived folder in the _Archive folder on the fileserver.
In this case:
fileserver/A/Aardvark/Projects/_Archive/archive.alias. -> archive/A/Aardvark/Projects/
or
fileserver/A/Aardvark/Projects/_Archive/000Job.alias -> archive/A/Aardvark/Projects/000Job/
Any help or suggestion is welcome!
PS. Yes, i do make backups of both drives.
Mac mini 2018 or later