• 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 manipulation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File name manipulation


  • Subject: Re: File name manipulation
  • From: Graff <email@hidden>
  • Date: Sat, 27 Dec 2003 20:23:04 -0500

This will swap around the name as you have requested. I'm not sure of how to go about changing under what application the file automatically opens in:
------------
set theFolder to choose folder
set oldDelims to text item delimiters
tell application "Finder"
set theList to every file in theFolder
repeat with currItem in theList
try
set theName to the name of currItem
set theExtension to ""
try
set AppleScript's text item delimiters to "."
set plainName to text item 1 of theName
set theExtension to text item 2 of theName
end try
if theExtension is "" then
set plainName to theName
end if
set AppleScript's text item delimiters to "_"
set firstElement to text item 1 of plainName
set secondElement to text item 2 of plainName
set nameString to secondElement & "_" & firstElement
if theExtension is not "" then
set nameString to nameString & "." & theExtension
end if
set (name of currItem) to nameString
end try
end repeat
end tell
set text item delimiters to oldDelims
------------

- Ken

On Dec 27, 2003, at 7:32 PM, Rob Lewis wrote:

I have a folder with over 500 files in it. The file names are of the form:

Item_Topic.html

I would like a script to change the files names to:

Topic_Item.html

(just interchange the text on either side of the underscore and before the suffix).

While I'm at it, I'd like to change the "open with" parameter from Internet Explorer to Safari.

Hints or tips? TIA. _______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: File name manipulation
      • From: Walter Ian Kaye <email@hidden>
References: 
 >File name manipulation (From: Rob Lewis <email@hidden>)

  • Prev by Date: Re: [OT] Shell scripting
  • Next by Date: [OT] Shell scripting (2)
  • Previous by thread: File name manipulation
  • Next by thread: Re: File name manipulation
  • Index(es):
    • Date
    • Thread