Copy to USB - only the latest files

I’d like automatically copy the latest 3 or 4 files from a folder to my USB disk and eject once done. While I’ve seen the option to copy an entire folder, I haven’t see the option to copy latest files only. Also what would the best way to eject the usb? Should I wait for x seconds and then eject?


Hey @skyblue,

Latest according to what?

Creation date?

Modification date?

Date added?

What kind of files would be in the folder?

Is it 3 OR 4? Exactness is required there.

What kind of files – very important due to issues with packages.


Hi @ccstone

Sorry, latest according to modification date.

The files are 1password backup files; so .1p4_zip files. Let’s say 4. My usb drive is small so it can’t accommodate many files but 4 should be fine.


The shell command ls -lt will return the files in date order.

cd /Volumes/Whatever; ls -t

Save that to a variable, and then use For Each action with the Lines In collection to iterate through the list. Set a Count variable initially to 0, and if the line ends with .1p4_zip, copy the file and increment the count. if the Count gets to 3 or 4 then break out of the loop.

After the loop, eject the disk.