One more question...
How would I alter it if i wanted more than one file type consolidated? I usually have 2 different file extensions that my audio program creates and I want to put them both in one folder.
Again thanks for all your help!
I tried to duplicate it and run it again with a different extension in the 'zip' line but it throws an error...
How would you keep JUST the most recent file and move all others? Is it pretty simple cause I don't want to keep bugging you but that's the last thing I was hoping to do with KM. I thought if I could get this far I'd be able to get it on my own but I know zip about shell scripting
[edit]
It would only be 1 file type for this action though
Another option you have is to use Hazel, which is built specifically to monitor files and folders and then act on them based on criteria you set up. Many KM users also employ Hazel, and the two apps work well together.
I have several Hazel actions that move and/or rename files after a period of time. For instance, I take a lot of screenshots, so I have Hazel actions that keep screenshots I've taken in the last 48 hours on my desktop, but anything older gets moved to an archive and sorted into dated folders (year and month). Other types of files that land on my Desktop, Downloads, and dozens of other folders have similar do-something-if-file-is-older-than actions.
Okay. I've given you an AppleScript solution for leaving the most recent file-pair in place, but I couldn't resist doing the job in the shell for practice.
It was quite fiddly to get it running on Bash 3.2.57(1), which is stock on Sierra and still stock on Mojave! That silly thing goes back to 2007.
I have Bash 5.0.17(1) on my system – installed via MacPorts (although Homebrew is probably easier to use).
I wonder what's stock on Big Sur...
In any case – I've got this running on both my macOS 10.12.6 Sierra and my macOS 10.14.6 Mojave systems.
I've commented the Bash script reasonably thoroughly, but I haven't gone out of my way to make it easy for the user to modify.
Thanks for all of your hard work on this! I only needed the 1 file type (cpr) saved ion the most recent but I'm sure I can figure out how to alter it (hopefully haha)
In the past, I've learned a lot and "Frankensteined" together some useful macros for myself using your scripts. With this specific macro, I don't have the knowledge to accomplish what would be helpful for me. Using this macro, I get close, but no cigar, and I don't want to screw things up!
For me, this scenario would be ideal:
If within Finder, I could point to (highlight) a root folder that contains many other folders, and have KM search all of the folders within the selected folder for specific file types, then copy those files to a new folder within the originally selected folder.
Hey, Chris. I'm curious why you split the extension from the full file path rather than simply applying the regexp match (slightly modified) to the path itself. You must be accounting for some edge case where the results would be different. Yes? Curious what that is. Thanks. –Steve
Thanks, Chris. Yes, absolutely true that your solution very clearly performs the operations specified in the problem. Without that extra step someone might well have asked a question like mine in reverse. Thanks for the response! –Steve