Skip to content

Instantly share code, notes, and snippets.

@firedynasty
Created July 6, 2022 23:02
Show Gist options
  • Save firedynasty/1060b6c9e73aabdd22c941c0e9bdcc15 to your computer and use it in GitHub Desktop.
Save firedynasty/1060b6c9e73aabdd22c941c0e9bdcc15 to your computer and use it in GitHub Desktop.
set text item delimiters to "."
tell application "Finder"
set all_files to every item of (choose file with prompt "Choose the Files you'd like to rename:" with multiple selections allowed) as list
--now we start looping through all selected files. 'index' is our counter that we initially set to 1 and then count up with every file.
--the 'index' number is of course required for the sequential renaming of our files!
set thefileList to {}
repeat with index from 1 to the count of all_files
--using our index, we select the appropriate file from our list
--this variables below are getting the name of files
set this_file to item index of all_files
set testpath to POSIX path of this_file
set testname to name of (info for testpath)
set a_ to count testpath
set b_ to count testname
set minus_ to a_ - b_
set oddManOut to text 1 thru (minus_) of testpath
set end of thefileList to testpath
--storing those names of files and paths into an applescript array
end repeat
--congratulations for successfully accomplishing the batch renaming task :)
end tell
set myVar to ""
repeat with a from 1 to length of thefileList
set theCurrentListItem to item a of thefileList
-- Process the current list item
set myVar to myVar & item a of thefileList & " "
end repeat
tell application "Terminal"
activate
do script "convert -append " & myVar & oddManOut & "jpg_output.jpg" in window 1
-- if this does not work then use echo and quoted form of myVar
do script "echo copy and paste add convert" in window 1
delay 1
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment