Re: Sorting files, making folders
Re: Sorting files, making folders
- Subject: Re: Sorting files, making folders
- From: Steen Villumsen <email@hidden>
- Date: Tue, 06 May 2003 11:44:04 +0200
Got it working - extremely cool!
But, when I showed it to my collegues who are going to be using it, some new
issues emerged:
The file-names include file-suffixes, so their name is something like
"A032202.JPG" instead. Furthermore sometimes I have more than a houndred
pages, and the filename will for instance be "A0322102.JPG" if the page is
102.
So I guess my script needs to extract the characters using a code like
"characters -7 through -5" and then know if the result is "02." it's suppose
to throw away the period.
Is this at all possible?
Once again, thanks to everybody for their help (and patience with a newbie),
kind regards,
Steen
Den 01/05/03 21:24, 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.