MACSCRPT Archives

August 2007

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Stockly, Ed" <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Thu, 16 Aug 2007 19:27:01 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (60 lines)
>>>When I try to change the choose folder to choose file, I get the following
error.

>[quote]
>Finder got an error: Can't get file {alias "Macintosh
>HD:Users:sprale:Desktop:test eps files:03EM01301CZ06015A4.eps"} whose
>{"eps", "ai", "ART1", "ART2", "ART3", "ART4"} contains name extension or
>kind contains "Postscript" or kind contains "EPS" or kind contains
>"Illustrator" or kind contains "ART5".
>[/quote]
  >  --    set FileSample to (choose folder) --use this one instead if you
want to process an entire folder
  >  set FileSample to choose file with prompt "Select multiple files with
the Command (Apple) key." with multiple selections allowed without
invisibles

 >   set folderName to name of (info for FileSample) --only necessary if
needed for myList
    
 >   tell application "Finder" to set theFiles to files of folder FileSample
whose name extension is in {"eps", "ai", "ART1", "ART2", "ART3", "ART4"} or
kind contains "Postscript" or kind contains "EPS" or kind contains
"Illustrator" or kind contains "ART5"
    
Levon, you're definitely making progress on this script.

Here's what's happening. When you use the Choose folder command you're
selecting a container (either a folder or a volume) which contains files.
With your next command you're looking into that container for files of a
specific type.

When you're using the choose file command you're selecting specific files.

The error occurs when you try to apply the get files commands to a file
instead of a directory.

Something like this may get you back on track:

----------
 set picFolders to false
if picFolders then
    set FileSample to (choose folder) --use this one instead if you want to
process an entire folder
    tell application "Finder" to set theFiles to files of FileSample whose
name extension is in {"eps", "ai", "ART1", "ART2", "ART3", "ART4"} or kind
contains "Postscript" or kind contains "EPS" or kind contains "Illustrator"
or kind contains "ART5"
else
    set theFiles to choose file with prompt "Select multiple files with the
Command (Apple) key." of type {"eps", "ai", "ART1", "ART2", "ART3", "ART4"}
with multiple selections allowed without invisibles
end if
if the class of theFiles is not list then set myFiles to {myFiles}
 
--------- 

HTH,

ES

ATOM RSS1 RSS2