Re: Count files
Re: Count files
- Subject: Re: Count files
- From: Roger_Jolly <email@hidden>
- Date: Tue, 13 Aug 2002 10:55:34 +0200
Hi Peter,
How about this:
tell application "Finder"
set TheFiles to every item of folder "testfolder"
end tell
set ExtraZeros to length of ((count of TheFiles) as string)
set IndexNumber to 1
set ChangeBase to 1
repeat with TheFile in TheFiles
if (IndexNumber mod ChangeBase = 0) then
set ChangeBase to ChangeBase * 10
set ExtraZeros to ExtraZeros - 1
set NewNameZeros to ""
repeat ExtraZeros times
set NewNameZeros to NewNameZeros & 0
end repeat
end if
set TheExtension to ".doc" -- or to name extension of (info for (TheFile
as alias))
set NewName to NewNameZeros & IndexNumber & TheExtension
tell application "Finder" to set name of TheFile to NewName
set IndexNumber to IndexNumber + 1
end repeat
Roger
on 13-08-2002 08:39, Peter Mathiessen at email@hidden
wrote:
>
Hi all,
>
>
I am in need of a script that renames the files in a folder.
>
>
Today I am using a random number, but a neat solution would be to use a
>
counter of some sort.
>
>
If the folder contains 3 files, the filename would be:
>
001.doc
>
002.doc
>
003.doc
>
>
Anyone?
>
>
>
>
>
get random number from 1000 to 3000
>
set x to result
>
set search_for_file to alias (the_vol & "Documents:")
>
set myListforfile to list folder search_for_file without invisibles
>
repeat with myFilename in myListforfile
>
set myfile to alias (the_vol & "Documents:" & myFilename)
>
end repeat
>
tell application "Finder"
>
set name of myfile to (x as string) & ".doc"
>
end tell
_______________________________________________
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.
References: | |
| >Count files (From: Peter Mathiessen <email@hidden>) |