I have a huge list of folders named in a specific way. Tried finding something similar on the forum but didn’t find much. Came across a script for exporting raws to jpgs though This is why I love this forum. Always find stuff to simplify your workflow whether you were looking for it or not.
But I have a huge list of folders, and then will drop JPG’s files into them once done. But I am wanting to rename the JPGS files with the same name as the folder. There will be only a max of 6 files in each folder. Here is an example of the folder name. 1234567890_1_brown
How can I have it change the sequential number to just go from 1-6 if there is more than one file in the folder.
Also once its complete is it possible to select all of the same files and move it to a new destination folder.
Thanks.
Ryan
This should get you started. You just select the files you want to rename in a Finder window and then run this script. Now that you can see the basics you can modify it to make it work exactly how you want.
tell application "Finder"
set theFiles to the selection
if theFiles is {} then error "No files are selected."
set folderName to name of container of (item 1 of theFiles)
repeat with i from 1 to count of theFiles
set thisFile to item i of theFiles
set ext to name extension of thisFile
set name of thisFile to (folderName & "_0" & (i as text) & "." & ext)
end repeat
end tell
hey regulus6633,
This just adds the sequential number to the end. I am wanting to change the number in the middle of the filename.
This would be my parent folder:
1234567890_1_brown
And the files inside of it would need to be renamed to this:
1234567890_1_brown
1234567890_2_brown
1234567890_3_brown
1234567890_4_brown
Let me know if that makes sense.
OK. Well the concept is the same so it’s time for you to do some learning of how to work with strings. You basically need some method to cut up the string into pieces and then add the pieces back together while appending the number. There’s several ways to do this, for example you can use the “words” command or applescript’s text item delimiters.
So the best way for you to learn about these things is to look at this post. Try some of those techniques and if you need more help post what you tried.
http://macscripter.net/viewtopic.php?id=24725
By the way, this MacScripters website has many tutorials. The tutorial above is complicated but if you want to start at the beginning look here… http://macscripter.net/viewtopic.php?id=25631. When I learned I did the ones titled “AppleScript Tutorial for Beginners”.
Good luck!