Last active
December 26, 2016 15:29
-
-
Save ruvasik/fcc90970a6aaf3a9de780788958cd6de to your computer and use it in GitHub Desktop.
Renaming files (jpg) in the folders to sequential numbers order starting with 1 in every folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set text item delimiters to "." | |
tell application "Finder" | |
set the_folder to choose folder | |
set the_subfolders to every folder in the_folder | |
repeat with index from 1 to the count of the_subfolders | |
set this_folder to item index of the_subfolders | |
set img_files to (every file in this_folder whose name ends with ".jpg") | |
repeat with indexf from 1 to (the count of img_files) | |
set this_file to item indexf of img_files | |
set file_name_count to text items of (get name of this_file) | |
if number of file_name_count is 1 then | |
set file_extension to "" | |
else | |
set file_extension to "." & item -1 of file_name_count | |
end if | |
set the name of this_file to indexf & file_extension as string | |
end repeat | |
end repeat | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment