Video_Beagle

Applescript to reverse file name

Jul 12th, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set thefile to choose file
  2.  
  3. tell application "Finder"
  4.     set filename to name of thefile
  5.     set rfilename to reverse of characters of filename as string
  6.     set rtheSuffix to text 1 thru ((offset of "." in rfilename)) of rfilename
  7.     set thesuffix to reverse of characters of rtheSuffix as string
  8.     set filenamereverse to text ((offset of "." in rfilename) + 1) thru -1 of rfilename
  9.     set name of file thefile to filenamereverse & thesuffix
  10. end tell
  11.  
  12. (* Rev 1
  13. set thefile to choose file
  14.  
  15. tell application "Finder"
  16.     set filename to name of thefile
  17.     set thePrefix to text 1 thru -5 of filename
  18.     set thesuffix to text -4 thru -1 of filename
  19.     set filenamereverse to reverse of characters of thePrefix as string
  20.     set newname to filenamereverse & thesuffix
  21.     set name of file thefile to filenamereverse & thesuffix
  22. end tell
  23. *)
Advertisement
Add Comment
Please, Sign In to add comment