Tuesday, 22 July 2014

AppleScript renaming files with unique name


hello everyone,

hope go easy on me since i'm quite new mac world, used pcs last 30 years of life has decided leave dark side :)

i'm having trouble solving i'm used doing on pcs on mac, , it's renamning files.
i've read lot of articles , forum posts , checked lot of youtube clips on applescript, automater , terminal haven't found answer question.

want pretty simple.
have bunch of files add predefined unique text to, see example below.
old file name new file name
file1.xxx file1-uniquetext1.xxx
file2.xxx file2-uniquetext2.xxx
file3.xxx file3-uniquetext3.xxx
file4.xxx file4-uniquetext4.xxx
file5.xxx file5-uniquetext5.xxx
file6.xxx file6-uniquetext6.xxx

used simple on windows using .bat file.
got original name folder files.
got unique texts( in case tv-show titles) internet.
did excel magic , put .bat file looking this.
rename file1.xxx file1-uniquetext1.xxx
rename file2.xxx file2-uniquetext2.xxx
rename file3.xxx file3-uniquetext3.xxx
rename file4.xxx file4-uniquetext4.xxx
rename file5.xxx file5-uniquetext5.xxx
rename file6.xxx file6-uniquetext6.xxx


able me using applescript?
save day , me not having return windows simple task this.
appreciate help!

in advance!!
 

you'd better off using shell script this.

basically, exact same thing bat file, instead of "rename" use "mv" (so you'd have lines "mv file1.xxx file1-uniquetext1.xxx" .

add "#! /bin/bash" first line of file, , save .sh extension. then, in terminal, perform "chmod u+x yourfile.sh" (replace file name needed, not include quotes), , "./yourfile.sh" run it. can edit script later different sets of files , won't need re-run chmod line.

edit: above assumes put shell script in home folder. if somewhere else, use full path file in both cases.

note: if files renamed not in home folder, either put full paths in shell script (so "mv /full/path/to/file1.xxx /full/path/to/file1-uniquetext1.xxx" ), or put shell script same folder files, , before chmod above, type "cd " (not trailing space, , not hit enter), drag folder containing script terminal. press enter. put right directory, can chmod make executable , run ./yourfile.sh line.
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment