0

I have a folder called FolderA and a folder called FolderB.

A process that runs in the background - not under my control - writes a file in FolderA every 1 minute or so. It erases the previous file. There is always only one current file with a new name in FolderA.

I want to copy that file in FolderA to FolderB, rename it to file1.jpg and on the next run, as soon as the file in FolderA has changed, copy that new file to FolderB and call it file2.jpg and so on so that after N steps I have N files in FolderB, with the last file called fileN.jpg.

Can I do this as an automator script app? Or how else?

1

One can use rerun by installing it using pip install rerun

Then in the terminal, in the directory (FolderA) where the files to be watched are located, type:

rerun "cp 1*.jpg /Desktop/FolderB"

Automator script to rename files in FolderB can then run as it is not located in a Hidden Folder.

You may need sudo to run pip

1
  • You generally don't need sudo to run pip, running it as a regular user just means anything you install with it gets installed just for that user rather than globally.
    – Shadur
    Oct 20 '20 at 18:02
0

Automator? Maybe... I don't use it, so can't say if it will or not.

I do know that launchd can do it. The trick is creating the .plist file written properly so that launchctl will process it for consumption by launchd. That's a PITA because Apple does an incredibly sorry job with documentation (IMHO).

Fortunately, there's a 3rd party tool that takes up the slack - it's called LaunchControl. I've used it to do something similar: I monitor a file for changes, and once a change has been detected, I launch rsync to do a backup. The support is great with LaunchControl also.

If my praise seems suspiciously enthusiastic, please know that it's not due to any affiliation with LaunchControl. Rather, my enthusiasm comes from the experience of having manually written & debugged a much simpler .plist file! It was one of the most frustrating nut-rolls of all-time. Never again...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.