Copy Latest File to Another File

Hey guys
Ive tried to do some searching but not finding much that work for my tiny brain.

I have a macro that is changing my life when it comes to backing up files, but theres one particular folder that id like to only copy the latest (date) file (its a backup format) and copy to another folder and preferably delete the last file that was in there.

Basically a program auto backups to folder X every time a change is made.
when i do my backups theres not enough space to copy the entire folder X, so id like to only copy the latest backup file to folder Y, where the last time i backed up, that file would be erased (preferably) and replaced with this latest file ie there would only ever be one file in folder Y - the latest one

I have made a work around but it is clunky and caveman like at best. (open folder X, page down, copy, minimize window, open folder Y, cmd a delete, paste, minimize window) (savage, i know)

Hey Jerry,

Have a look at this topic:

Open the Most Recently Added File in a Specific Folder?

-Chris

you guys are amazing. i really need to learn how to use these variables and tokens etc

I'd be remiss if I didn't start with the easiest solution -- get more backup space! Then you could sync the whole of folder X to folder Y and rely on the app's backup grooming to keep the numbers under control.

While any backup is better than none, your plan puts you in the precarious position (even if only for a short time) of having no backups -- what happens if you delete the file from Y and your Mac implodes before copying the new file completes?

Otherwise... what @ccstone said :slight_smile: And you could also use the "For Each" action for the deletion as well -- a single file in that folder would just mean a single item in the gathered collection, and you could delete it without having to find the file name by other means.

The macro Mirror Mirror has a File option that will backup a file to some other folder and remember the task to make it easy to repeat it on demand.

nah each backup is a single file but its an entire collection so theres no need to copy the previous ones as the whole batch is outdated but thank you

The whole batch is outdated unless the latest copy was corrupted on transfer or something -- but, as I said, it's something that should be mentioned even if you decide it isn't important.

I'm cavalier with my own data, but very cautious with other people's :wink: