[thelist] Applescript to change file extensions
Matthew Fischer
mfischer at e-fishsolutions.com
Fri Sep 29 14:14:33 CDT 2000
This will prompt you for the name of the folder, the extension you want to replace and what you want to replace it with. Be sure to include the dot, as in .jpg, in both the old and new extensions. The way this is written it will not search subfolders of the folder you select. If you want to include subfolders change:
every file in thePath whose name ends with ext
to
every file in the entire contents of the thePath whose name ends with ext
<START APPLESCRIPT>
set thePath to choose folder with prompt "Select folder to rename files in:"
set ext to display dialog "Extension to Replace:" default answer ""
set ext to text returned of ext
set extNew to display dialog "Replace With:" default answer ""
set extNew to text returned of extNew
tell application "Finder"
try
set the datlist to ¬
((every file in thePath whose name ends with ext) as alias) ¬
as list -- set name criteria
on error number -1700 from f
set datlist to f as list
end try
repeat with dat in datlist --list of alias references to the files
select file dat
set workingName to the name of dat as text
set theOffset to offset of ext in workingName
set chopped to characters 1 through (theOffset - 1) of workingName
set newName to chopped & extNew as text
set name of selection to newName
end repeat
end tell
<END APPLESCRIPT>
HTH
On 9/29/00 at 1:03 PM, sallyevans at eden.com (Charlie Llewellin) wrote:
> Any Applescript person have such a script - to run through a folder and
> change file extensions - ie, from .html to .php?
>
> If you did, I would be very grateful!
>
> Charlie Llewellin
>
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !
^^^^^^^^ >e}e}}@> ^^^^^^^^
Matt Fischer | e-fish solutions, inc.
877.WEB.FISH | 203.272.2987 | Fax 800.203.5816
mfischer at e-fishsolutions.com | http://e-fishsolutions.com
More information about the thelist
mailing list