Re: Move .ps files to Distiller Watched Folder?
Re: Move .ps files to Distiller Watched Folder?
- Subject: Re: Move .ps files to Distiller Watched Folder?
- From: has <email@hidden>
- Date: Tue, 2 Oct 2001 20:57:53 +0100
Jerry Meyer wrote:
>
Can I "Add" the following process to an existing Script that prints a .ps
>
file to disk. The .ps files are created in the same folder as the original
>
PageMaker docs. I want to have the export to .ps portion of the script
>
complete and then have all files with a .ps extension moved to an Acrobat
>
Distiller Watched folder. Here's what I have so far...
>
>
set foldertoprocess to (choose folder with prompt "FilesToConvert")
>
>
tell app "Finder" to set filestoprocess to every file in foldertoprocess
>
>
tell app "PageMaker"
>
do script -- lots of app specific stuff here
>
end tell
>
----------------------- here's where I need help ------------------------
>
set filestomove to (files in "FilesToConvert" whose name contains ".ps")
>
>
tell app "Finder"
>
relocate filestomove to "distillerfolder"
>
end tell
Hey Jerry, you still bashing away at that old thing, huh? ;)
This will sort the wheat from the chaff for you:
--get path to Distiller's watched folder
set distillerfolder to choose folder with prompt "Select the distiller folder"
Put this line at the top of the script, alongside the 'set
folderprocess...' line.
You might prefer to hardcode value this since it probably always points to
the same folder anyway,
e.g. set distillerfolder to alias "Jerry's Hard Disk:Desktop
Folder:Distiller's Watched Folder:"
And this goes after the Pagemaker Tell block, replacing what you've
currently got:
tell app "Finder"
--get a list of all files whose names end with a .ps suffix
set filestomove to (every file in foldertoprocess whose name ends with
".ps")
--move those files to the desired folder
move filestomove to distillerfolder
end tell
OTOH, you could print the ps files to a separate folder to begin with. Two
ways you could do it: 1. use the second script I originally sent -
(assuming the thing was bug-free, since it was untested) it was designed to
do just this; or 2. in amongst PM's myriad layout commands is one that
allows you to specify a "default folder" for PM to use (see PMScript book)
- I'm not entirely sure how this works, to be honest, since I never used it
myself, but I expect it would do the job as well.
Also, for my money, if both processes are done on the same maching then I'd
wait til PM had finished its bit before starting the batch Distill. If the
files go to another machine for distilling, however, I'd not wait time
before starting to distill: I'd send Distiller each ps file as soon as it
was created.
-----
>
Am I missing some needed additions. I've also caught a few threads related to
>
the location of scripting files/info on the hardrive... my Scripts &
>
Scripting Additions folders are in the System Folder. Should they be in the
>
Extension Folder? Any help appreciated!
Nope, I don't imagine you're missing anything. Those folders are exactly
where they should be.
Your problem is that you've not quite gotten into the AppleScript mindset
yet and don't quite know how to tell AS what you want it to do. No biggie:
we've _all_ been there at one time or another....<g>
Your problems:
1. The app keyword 'relocate' does not exist in the Finder's dictionary;
what you need to use is the keyword 'move'. Take a look at the Finder's
dictionary to see what's on offer (in Script Editor, select 'Open
Dictionary...' under the File menu). Amongst all the other keywords you'll
see:
move : Move object(s) to a new location
move reference -- the object(s) to move
to location reference -- the new location for the object(s)
[replacing boolean] -- Specifies whether or not to replace items in
the destination that have the same name as items being moved
[positioned at list] -- Gives a list (in local window coordinates) of
positions for the destination items
[routing suppressed boolean] -- Specifies whether or not to autoroute
items (default is false). Only applies when moving to the system folder.
Result : reference -- to the object(s) after they have been moved
Looks intimidating, but all you need is "move x to y", where x is a
reference to the file(s) you want to move, and y is a reference to the
folder you want to move those files to. The stuff in brackets is optional
and you won't need those here.
2. "distillerfolder" isn't a proper reference to a folder - you need to use
an alias to the desired folder. e.g. Try a simple test in Script Editor:
run "choose folder" and see what appears in the Result window. It'll look
something like:
alias "Macintosh HD:Desktop Folder:Watched Folder:"
The second bit is a string containing the complete path to the folder; the
first bit tells AS to coerce (convert) this boring old string to a
wonderfully exciting file/folder alias. Hey presto! - you've got a pointer
to a particular folder on your hard disk. There's other ways of referring
to items on a disk, but this is the simplest and most commonly used.
-----
If you're completely new to programming this stuff just takes a bit longer
to wrap your head around. Trying to get a real project up and running is
probably the worst place to start trying to learn too (running before
walking)... most folks would start out with a few "Hello World"s to get
accustomed before trying to do what you're doing!:)
I recommend that once you get this thing up and running, you go invest in a
good AS book with lots of lessons and tutorials, and start learning from
the basics. In case there's ever a Next Time, y'unnerstand... you just
never know when this stuff might be useful.;)
has