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

Re: File Name Change


  • Subject: Re: File Name Change
  • From: kai <email@hidden>
  • Date: Tue, 19 Apr 2005 00:17:43 +0100


On Mon, 18 Apr 2005 17:33:26 +1000, Matthew Smith wrote:

on 18/04/2005 16:58, Dustin Bell at email@hidden wrote:

I am confused. Is the WT in the file name? If you delete the name of the
file then you don't have a file name.
Are you wanting to change any occurrence of GT in file names to Greeley?


Matthew Smith
--
Sorry Matt I should have made myself clearer, the File names are WT001,
WT002, WT003 etc I just want it to be 001, 002, 003 and yes I am wanting to
change any occurrence of the letters GT in file names to Greeley.

Here's how to do the first bit:

set theFolder to choose folder
tell application "Finder"
    set fileList to every file in theFolder whose name starts with "WT"
    repeat with oneFile in fileList
        set oldName to name of oneFile
        set newName to text 3 thru -1 of oldName
        set name of oneFile to newName
    end repeat
end tell

And here's a way to achieve the second:

--------------------

to changeNameStrings at currFolder from searchStr to replaceStr
tell application "Finder" to try
set oldList to name of currFolder's files whose name contains searchStr
on error number -1728 -- no matching filenames
return
end try
set tid to text item delimiters
set text item delimiters to return
set newList to oldList as string
set text item delimiters to searchStr
set newList to newList's text items
set text item delimiters to replaceStr
set newList to (newList as string)'s paragraphs
set text item delimiters to tid
tell application "Finder" to repeat with i from 1 to count oldList
set name of currFolder's file (oldList's item i) to newList's item i
end repeat
end changeNameStrings


changeNameStrings at (choose folder) from "GT" to "Greeley"

--------------------

---
kai

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Illustrator CS Rotation
      • From: Rob Stott <email@hidden>
  • Prev by Date: Re: How to Renew DHCP Lease
  • Next by Date: Re: How to Renew DHCP Lease
  • Previous by thread: Re: File Name Change
  • Next by thread: Illustrator CS Rotation
  • Index(es):
    • Date
    • Thread