Re: List sorting dilemma
Re: List sorting dilemma
- Subject: Re: List sorting dilemma
- From: "Arthur J. Knapp" <email@hidden>
- Date: Thu, 25 Jul 2002 14:15:44 -0400
>
From: Rips Ethan J <email@hidden>
>
Subject: List sorting dilemma
>
Date: Thu, 25 Jul 2002 09:39:33 -0400
>
I'm writing a script that lists the (graphics) files in a folder on our
>
Win2000 server, sorts them in numerical order & inserts each into a new
>
Quark document. (I've reverted to OS 9.2.2 on a G4/800 for this project due
>
to OS X 10.1.5's access restrictions on our Win2000 server.)
>
I'm able to access the list of files, but in attempting to use a quicksort
>
implementation (posted a while back by Arthur Knapp-not that he's
>
responsible for any of my -er- results), the quicksort handler gets a stack
>
error.
>
--First, I assign the path to the folder to var imagepath:
>
set imagePath to alias "Production:Fact Sheets:= 2002:06_02 Fact Sheets:Pie
>
Charts:" as string
The above is a bit unusual. You are doing this:
alias "MacHD:myFolder:" as string
which is simply returning a string, ie:
alias "MacHD:myFolder:" as string = "MacHD:myFolder:" --> true
Just do this:
set imageFolder to alias "blah:blah:PieCharts:"
>
--Then the list of items in that folder to var imageList:
>
set imageList to every item of alias imagePath
tell app "Finder"
set sortedImages to sort (every file of imageFolder) by name
The images are now sorted by name. The problem you are going to
have now is converting the Finder objects in to aliases so that
Quark can work with them:
tell application "Finder"
set sortedImageFiles to ,
(sort (every file of imageFolder) by name)
end tell
repeat with aFile in sortedImageFiles
set aFile's contents to aFile as alias
end repeat
sortedImageFiles --> list of aliases
>
Is there a way to reference a file such that the returned values take the
>
form folder:folder:folder:file? I wonder if that might affect the results
>
I'm getting...imageList --the script never gets this far.
Yes, you can use the "as alias list" syntax. Unfortunately, I can't
seem to get this to work in conjunction with the Finder's "sort" command.
tell app "Finder"
try
set aliasList to (every file of folder) as alias list
on error
set aliasList to (every file of folder) as alias as list
end
>
I also need to figure out how to access the names of the graphics files so I
>
can concatenate them to imagePath to insert the graphics programmatically,
>
like so:
>
>
set image i to alias (imagePath & nameOfImage_i)
Within the Finder, you can simply access the "name" property of a file
or folder:
name of aFinderReference
If you are working with aliases or path-strings, this handler will
do the job:
on GetFileName(f)
(*
* f == path-string, alias, or Finder ref
*)
try
set f to ("" & alias ("" & f)) --> string
on error n number m
error "GetFileName( fileRef ) --> fileRef does not exist."
end try
set o to text item delimiters
set text item delimiters to ":"
if (f ends with ":") then
set n to f's text item -2
else
set n to f's text item -1
end if
set text item delimiters to o
return n
end GetFileName
>
Ethan
>
Lost (as usual) in a forest of file & folder references.... <sigh>
;-) --> Is there a "sympathy" emoticon?
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m
}
_______________________________________________
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.