• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Renamer script (CafeTran Wiki)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Renamer script (CafeTran Wiki)


  • Subject: Re: Renamer script (CafeTran Wiki)
  • From: Christopher Stone <email@hidden>
  • Date: Sat, 09 Jan 2016 07:02:31 -0600

On Jan 08, 2016, at 11:25, Michael Schwarz <email@hidden> wrote:
Fri, 08 Jan 2016 16:43:33 +1100
I have a folder with 450 subfolders each containing one or more PNG files:
I want to rename the PNG files by adding the subfolder (plus a dash) to the file name

An example for a script to rename the files dropped on an applet or the files in a chosen folder is as follows.
______________________________________________________________________

I'd probably use the Satimage.osax and do something like this:

-------------------------------------------------------------------------------------------
# REQUIRES the Satimage.osax!!!!
# http://www.satimage.fr/software/en/downloads/downloads_companion_osaxen.html
-------------------------------------------------------------------------------------------

set srcFolder to alias ((path to home folder as text) & "test_directory:png.image.test:")
set fileList to list files srcFolder as alias of extension {"png", "PNG"}

tell application "Finder"
  repeat with theFile in fileList
    set parentFolderName to name of theFile's parent
    set theFileName to name of theFile
    set newFileName to cng("^(.+)(\\.png)$", ("\\1" & " - " & parentFolderName & "\\2"), theFileName) of me
    set name of theFile to newFileName
  end repeat
end tell

-------------------------------------------------------------------------------------------
--ยป HANDLERS
-------------------------------------------------------------------------------------------
on cng(_find, _replace, _data)
  change _find into _replace in _data with regexp without case sensitive
end cng
-------------------------------------------------------------------------------------------

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Renamer script (CafeTran Wiki) (From: Michael Schwarz <email@hidden>)

  • Prev by Date: Re: [ANN] CalendarLib, improved Calendar scripting
  • Next by Date: Re: Script to insert the file name in TextWrangler
  • Previous by thread: Re: Renamer script (CafeTran Wiki)
  • Next by thread: Re: How to Run a "sudo" Terminal Command
  • Index(es):
    • Date
    • Thread