Apple script automating renaming folder names
Hi there,
I am a beginner at using Applescript but i'm slowly learning the new syntax and structures from what I am used to in VB.net (which I used at high school)
I have already found a lot of help on this forum from the user "Camelot" where they answered a lot of my questions but I just cant manage to tie up my program to be completely finished and would be more than grateful to gain some help from the Apple Community.
My program is to rename image files.
I start with a folder (Lots) containing folders, like the following:
(1,2,3,4,5...900,)
In each of these folders is a group of images named as follows:
(Img_xxx1.jpg, Img_xxx2.jpg, Img_xxx3.jpg, Main.jpg)
The goal outcome of this little program is to rename Main.jpg to the name of the folder it is in and the rest of the images to the name of the folder with the _x.jpg suffix.
So in the first folder (1) inside the folder will look like the following:
(1.jpg, 1_1.jpg, 1_2.jpg, 1_3.jpg)
and for example inside folder (564) will look like the following:
(564.jpg, 564_1.jpg, 564_2.jpg, 54_3.jpg)
This is what I currently have:
on run
set Thefolder to (choose folderwith prompt "select start folder")
RenameContents(Thefolder)
end run
on RenameContents(aFolder)
tell application "Finder"
set subFolders to every folder of aFolder
repeat with eachFolder in subFolders
end repeat
end tell
end RenameContents
Thank you for any help in advance.
MacBook Pro (13-inch Mid 2012), macOS High Sierra (10.13.1), AppleScript