Re: renaming files in Finder
Re: renaming files in Finder
- Subject: Re: renaming files in Finder
- From: Mr Tea <email@hidden>
- Date: Mon, 4 Feb 2002 22:28:55 +0000
This from Stephen Swift
>
At 2/4/02 11:06 AM, William Porter (email@hidden) Wrote:
>
>
> on run
>
> set myFolder to choose folder
>
> addprefix(item 1 of myFolder as alias)
>
> end run
<snip>
>
Why would you need the subroutine in the first place?
Hey, subroutines are all the rage. Haven't you heard? :-)
>
>
Wouldn't this be a much easier approach?
>
>
on run
>
set myFolder to choose folder
>
--asks you what folder
>
tell application "Finder"
>
repeat with x in every file of myFolder
>
set name of x to ("temp " & name of x)
>
end repeat
>
--adds "temp" to all file names in myFolder
>
end tell
>
end run
Easier, perhaps, but no more effective on my OS 10.1.2 with AS 1.8.2b.
The Finder likes it better if the files in the folder are put into a
variable first...
set myFolder to choose folder
tell application "Finder"
activate
set theFiles to every file of myFolder
repeat with x in theFiles
set name of x to ("temp " & displayed name of x)
end repeat
end tell
Note that I have used the 'displayed name' property when getting the
original name of the file. This is because, during testing, the Finder
showed an unfortunate tendency to add the extension (to url and text
clippin files in my test) where it was not displayed before.
Even easier than this, make the script into a droplet that you can just
drag a folder onto: replace the line "set myFolder to choose folder" with
"on open {myFolder}", and folow the final end tell with a line that reads
"end open", and away you go. (Drag the folder icon from beside the name
in an open folder's title bar if you want to see the script working).
Note that this will only work on a single dropped folder. Ask for more
info if you want to drop multiple folders.
Regards
Mr Tea
"Always remember to warm the pot."