Re: Adding extensions to a large batch of files
Re: Adding extensions to a large batch of files
- Subject: Re: Adding extensions to a large batch of files
- From: Graff <email@hidden>
- Date: Thu, 03 Jun 2004 21:33:31 -0400
Here's a fairly simple script that works under Mac OS X 10.3.4 and I'm
pretty sure that it will work under Mac OS 9:
----
on open (theItems)
if class of theItems is not list then
set theItems to {theItems}
end if
set theResult to display dialog "What extension would you like to add
to the files?" default answer "" buttons {"Cancel", "Add"} default
button "Add"
if button returned of theResult is "Add" then
set theExtension to text returned of theResult
if length of theExtension is greater than 0 then
if character 1 of theExtension is "." then
set theExtension to text 2 thru -1 of theExtension
end if
tell application "Finder"
repeat until (length of theItems is 0)
set anItem to item 1 of theItems
if (kind of anItem is "Folder") then
set theItems to theItems & every item of anItem
else if (kind of anItem is "Application") then
-- do nothing
else
set (name of anItem) to (name of anItem & "." &
theExtension)
end if
set theItems to rest of theItems
end repeat
end tell
end if
end if
end open
----
There are some long lines there and sometimes they get miswrapped.
Make sure all of the lines are correct before compiling the script.
This line is the most likely to get miswrapped - make sure it is one
line:
"set theResult to display dialog "What extension would you like to add
to the files?" default answer "" buttons {"Cancel", "Add"} default
button "Add""
Save the script as an application and then drop files on it. If you
drop a folder on it then it will rename every item in all the folders
within that folder also. It doesn't rename folders or applications.
You can enter the extension with or without an initial period, it will
do the right thing. It doesn't strip the old extension, it just tacks
the new one on to the end of the name. More logic will have to be
added to the script if you want to strip the old extension first.
- Ken
On Jun 3, 2004, at 6:47 PM, Mike Owen wrote:
Can anyone give me a simple script that will add extensions to each of
a
large batch of files, moving from one file to the next till it reaches
the
last one? OSX or OS9.
Mike Owen
_______________________________________________
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.