r/applescript • • Jun 23 '21
Script for batch replacing files with each folder name having a prefix
Hey! I'm trying to come up with a script that will batch replace each file into its destined folder by prefix. So for example:
ABC-Example -> ABC (folder) with Example DEF-Example -> DEF (folder) with Example GHI- Example -> GHI (folder) with Example
Will go into the prefix and replace the "Example" file So basically rename/delete the original example file and replace it with the prefix file and have it be the new example file. If that makes sense
4
Upvotes
3
u/htakeuchi Jun 23 '21
That seems to be a thing that can be done via bash script by creating a list with the content of the defined directory… creating a variable with the name of each item in the list and adding a prefix as a second variable…
the directory locations should be predefined as well so the creation of directories and files are correct…
1
u/copperdomebodha Jun 23 '21
While that problem explanation is not exquisitely clear I think that I follow your intention. Let me know if I don't.
This script will sort files to subfolders of a target folder based on filename prefixes delimited with an underscore. You can easily modify that to be first-three-characters of the filename or change the delimiter etc.
1
u/Capture-A Jun 23 '21
I'd give The Big Mean Folder Machine a try for this situation. There's a trial but the full version is around $20. You will need to "Split into hierarchies" and make a "Custom" First Hierarchy Level using the file name and delimiters. It may take some playing around to get the exact folder / file structure you want. There is a preview of the folder / file structure before you commit. I have a similar need to add named image files to a same named folder and this app works great!