• 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: Change Photo Name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Change Photo Name


  • Subject: Re: Change Photo Name
  • From: "Bob.Kalbaugh" <email@hidden>
  • Date: Tue, 11 Sep 2001 18:09:33 -0500

on 9/11/01 2:19 PM, email@hidden at email@hidden wrote:

> but it will not actually change the name of the photo in the folder. Sure
> could use a little more help.
>

Leslie,

You'll need to tell the Finder to change the name of the file, however given
the structure of your script it -won't- be as easy as stating:

Tell app "Finder"
set name of file thisName to newName
end tell


Here is a script that may work for you. I have broken it up somewhat so that
you can see where I've made changes marked with --*

Compare it carefully. Also note that for some reason, OMM, I have to use
"AppleScript's text item delimiters" instead of just "text item delimiters"
I'm not sure if it's because I'm running OS 8.5.1. At any rate here goes.
(watch linebreaks!)

--script

set theFolder to (choose folder with prompt "Where are the files man?") as
text --*

set fileList to list folder theFolder

repeat with thisName in fileList

set tempName to thisName --*

set AppleScript's text item delimiters to "."
set thisName to item 1 of every text item of thisName
set AppleScript's text item delimiters to " "
set fileNumber to text item -1 of thisName
set AppleScript's text item delimiters to ""
set fileName to characters 1 thru -((length of fileNumber) + 2) of thisName
as text
set newName to fileNumber & " " & fileName & ".jpg "

set fileToChange to (theFolder & tempName) as text --*

--*
tell application "Finder"
set name of alias fileToChange to newName
end tell
--*
end repeat

--end script

Hope that helps.

--
bob.kalbaugh




> In a folder there are hundreds of photos, sample names are shown below.

>
> Bonanzaville 02218.jpg
> Clouds 00659.jpg
> Curio Cabinet 00418.jpg
> Dakota Bus College 02303.jpg
>
>
> This is how I want the name of photo in the folder to look.
>
> 02218 Bonanzaville.jpg
> 00659 Clouds.jpg
> 00418 Curio Cabinet.jpg
> 02303 Dakota Bus College.jpg
>
> Below is what I have now.
>
> --begin script
>
> set fileList to list folder (choose folder with prompt "Where are the files
> man?") as text
>
> repeat with thisName in fileList
> set text item delimiters to "."
> set thisName to item 1 of every text item of thisName
> set text item delimiters to " "
> set fileNumber to text item -1 of thisName
> set text item delimiters to ""
> set fileName to characters 1 thru -((length of fileNumber) + 2) of
> thisName as text
> set newName to fileNumber & " " & fileName & ".jpg "
>
>
> end repeat
>
>
> --end script


References: 
 >Change Photo Name (From: email@hidden)

  • Prev by Date: Re: property of a folder action script
  • Next by Date: Re: Scroll to top
  • Previous by thread: Change Photo Name
  • Next by thread: Re: Change Photo Name
  • Index(es):
    • Date
    • Thread