When you run this script, you’ll get a new option to select the new file extension for the files you want to rename. congratulations for successfully accomplishing the batch renaming task :)ĭisplay alert "All done! Renamed " & index & " files with ’" & new_name & "’ and file extension ’" & new_extension & "’ for you. let’s rename our file, add the sequential number from ’index’ and add the file-extension to it set the nameof this_file to new_name & index_prefix & index & file_extension asstring set file_extension to "" else -yup, we are currently processing a file that has a file-extension -we have to re-add the original file-extension after changing the name of the file! set file_extension to "." & new_extension lets check if the current file from our list (based on index-number) has even any file-extension if new_extension is "" then - "" means there is no file-extension present. Set index_prefix to "0" else set index_prefix to "" if the index number is lower than 10, we will add a preceding "0" for a proper filename sorting later using our index, we select the appropriate file from our list set this_file to item indexof all_files Repeatwithindexfrom1to the countof all_files the ’index’ number is of course required for the sequential renaming of our files! ’index’ is our counter that we initially set to 1 and then count up with every file. now we start looping through all selected files. Settext item delimiters to "." tell application "Finder" set all_files to every item of (choosefilewithprompt "Choose the Files you’d like to rename:" with multiple selections allowed ) aslistĭisplay dialog "New file name:" default answer "" set new_name totext returned ofresult
0 Comments
Leave a Reply. |