Re: Sorting files, making folders
Re: Sorting files, making folders
- Subject: Re: Sorting files, making folders
- From: Steen Villumsen <email@hidden>
- Date: Sun, 04 May 2003 19:57:58 +0200
Thanks Andrew,
The funny thing is, when I try your script (only changing the first line to
match my folder path), absolutly nothing happens...
It appears that the script runs (play button in ScriptEditor turns green),
and I don't get any error-messages.
Regards,
Steen Villumsen
Den 5/1/03 9:24 PM, skrev "Andrew Oliver" <email@hidden>:
>
This is relatively easy to do thanks to the Finder's ability to filter
>
filenames:
>
>
set sourceDir to "Macintosh HD:Source Folder"
>
repeat with pageNum from 1 to 99
>
set pageStr to pageNum as string
>
-- prepend leading zero if less than 10
>
if pageNum < 10 then set pageStr to "0" & pageStr
>
>
tell application "Finder"
>
-- here's the magic line
>
set filesToMove to (every file of folder sourceDir whose [NOBREAK]
>
name ends with pageStr)
>
-- do we have any hits?
>
if (count of filesToMove) > 0 then
>
-- so make a new folder
>
set targetDir to make new folder at sourceDir with [NOBREAK]
>
properties {name:"Page " & pageStr}
>
-- and move the files there
>
move filesToMove to targetDir
>
end if
>
end tell
>
end repeat
>
>
The idea here is to use the Finder's ability to filter files based on file
>
name, so you can get every file whose name ends in the specified string.
>
Running this in a loop from 01 to 99 covers all your pages, and if there are
>
any hits we make a new folder and move the relevant files there.
>
>
Andrew
>
:)
>
>
>
On 4/30/03 11:58 PM, "Steen Villumsen" <email@hidden> wrote:
>
>
> Hi there.
>
>
>
> As some of you may already now, I'm kinda new to scripting - but I'm
>
> learning eagerly :-)
>
>
>
> I need a little push in the rigth direction for my next project, so I don't
>
> expect any complete solutions from you guys ;-)
>
>
>
> Here's the deal, I have a lot (about 700) images with names like:
>
>
>
> A12345-06
>
> A12345-08
>
> A12345-12
>
> B12345-06
>
> B12345-07
>
> B12345-08
>
> C12345-06
>
>
>
> The last two digits in the filename refers to a pagenumber.
>
>
>
> Now here's the tricky part (well, tricky for a newbie like myself). I wan't
>
> my script to make a folder called "Page 01" and put all the files whose name
>
> ends with 01 in there.
>
>
>
> Sounds simple, huh? Well, not for me. Any help, script-snippets, pointers to
>
> websites etc., will be extremely appriciated.
>
>
>
> Kind regards,
>
> Steen Villumsen
>
> _______________________________________________
>
> 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.
_______________________________________________
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.