Re: Looking for a folder within a folder
Re: Looking for a folder within a folder
- Subject: Re: Looking for a folder within a folder
- From: Brett Conlon <email@hidden>
- Date: Wed, 31 May 2006 10:37:57 +1000
Thanks Michelle.
I've followed your suggestion and, just
in case you're interested, here's the full test script I ran this morning
succesfully:
(*The
other parts of the main script use a HiRes PDF to create a number of JPEG
images in a folder PACKSHOTS on the Desktop. With the help of the handler
below the PACKSHOTS folder is then supposed to be moved into their job's
Dispatch folder*)
on
run
set
aFile to
choose file with prompt "Please choose a file to process" --This
would be the HiRes PDF the user has chosen for processing
tell
application "Finder"
activate
set
PACKSHOTSFolder to
folder "PACKSHOTS" --On
Desktop
set
DispatchFolder to
container of
aFile --The PDF is supposed to
be processed from their job's "Dispatch" folder
try
repeat
until
name of
DispatchFolder contains
"Dispatch" --Testing
to see if it is inside the Dispatch folder.
set
DispatchFolder to
container of
DispatchFolder
end
repeat
on
error
--If the PDF isn't in the Dispatch
folder ask the user where to put the final PACKSHOTS folder
set
DispatchFolder to
choose folder with prompt "Sorry, the file you processed does not
appear to be from the job's Dispatch folder. Please choose where you want
the PACKSHOTS folder to be moved to?"
end
try
if
(path to desktop folder as string) contains
name of
DispatchFolder then
--This is for if the user chose
the Desktop as the destination
open folder "PACKSHOTS"
beep 3
display dialog "All Packshots have been named &
saved into a folder PACKSHOTS, on the Desktop (opened for your convenience)."
buttons {"Cool!"} default button 1 with icon 1
else
try
try
move PACKSHOTSFolder to DispatchFolder without
replacing --Simply moving it to
job's Dispatch Folder
on
error
msg number num -- errors if already
exists
if
num is
-15267 then
set
ifExists to
button returned of
(display dialog "A PACKSHOTS folder already exists in your job's Dispatch
folder. Do you want to replace it or add new packshots to it?" buttons
{"Cancel", "Replace it", "Add to it"} default
button 3 with icon caution) --
default button is 3 because it is most likely they have previously created
packshots for other movie titles in that job.
end
if
if
ifExists is
"Add to it" then
--Merge contents
set
OldPACKSHOTS to
folder "PACKSHOTS" of
DispatchFolder
move entire contents
of
PACKSHOTSFolder to OldPACKSHOTS with
replacing
else
--Simple replace
move PACKSHOTSFolder
to DispatchFolder with
replacing
end
if
end
try
delete PACKSHOTSFolder
--delete off Desktop
open folder "PACKSHOTS"
of
DispatchFolder
set
current view of
window "PACKSHOTS" to
list view
beep 3
display dialog "All
Packshots have been named & saved into a folder PACKSHOTS in your job's
Dispatch folder (opened for your convenience)." buttons {"Cool!"}
default button 1 with icon 1
on
error
display dialog "There
was an error moving the PACKSHOTS folder. It should still be located on
the desktop." with icon stop buttons {"DAING!"} default
button 1
end
try
end
if
end
tell
end
run
Ta muchly for your help,
Coj _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden