Re: Scripting Image Events - some kind of bug ?
Re: Scripting Image Events - some kind of bug ?
- Subject: Re: Scripting Image Events - some kind of bug ?
- From: Jay Louvion <email@hidden>
- Date: Thu, 15 Sep 2005 09:09:53 +0200
> In general, applications will not create folders for you when
> referencing a file. Sorry. However, if you don't want to do all the
> processing yourself, then there's a shortcut involving the shell,
> namely mkdir(1). This will rely on two tricks: first, the "POSIX
> path" property doesn't care (mostly) about whether or not any of the
> path components exist; second, mkdir(1) has a "-p" option that will
> create *all* the folders specified in the path. So, for instance:
>
> set p to thefolder &
> ":LDbogus_container:bogus_folder1:bogus_folder2:"
> do shell script "mkdir -p " & quoted form of POSIX path of p
>
> I'm breaking my own standard advice again by applying "POSIX path" to
> a string, but the upshot is that when this is done,
> LDbogus_container, bogus_folder1, and bogus_folder2 will all exist.
> (That's the other feature of -p -- it won't error if any of the
> folders already exist.)
>
>
> --Chris Nebel
> AppleScript and Automator Engineering
>
Thanks for the advice, it seems indeed to be one of the best ways of getting
the task done; I do though get an unexpected result you might be quicker
than me to explain:
Whereas in the script listed at the end of this mail, when asked to return
POSIX path of thefinalstring, the SE returns: "/Users/me/ EN
COURS/BuildingAS/HD/artistes/bogus_folder_name/LD_DSC_5603.JPG"
The images are actually being saved to "/Users/me/ EN
COURS/BuildingAS/HD/artistes/bogus_folder_name/LD_DSC_5603/LD_DSC_5603.JPG"
What's the extra folder about ?
(I can tell you that for 500 jpegs, that's gonna be a heck of a lot of
folders :-D )
TIA, J.
SCRIPT--
set thisFolder to (choose folder)
set decided_width to text returned of (display dialog "What width in pixels
should the images be resized to ?" default answer "")
tell application "Finder" to set EveryPicture to (every item of entire
contents of thisFolder whose name extension is "jpg") as alias list
set NumberOfFiles to number of items in EveryPicture
set incrementprogress to 0
set ImageResizeProgress to create progress indicator with properties {global
window:true, name:"Resizing Pictures", closeable:true, indeterminate:false,
top message:"This might take some time.", bottom message:"Please be
patient...", current value:0, minimum:0, maximum:NumberOfFiles}
with timeout of (length of EveryPicture) * 5 seconds
repeat with OneFile in EveryPicture
tell application "Finder" to set FileName to name of OneFile as text
set LDFileName to ("LD_" & FileName) as string
set TheFinalFileString to ((thisFolder as text) &
"bogus_folder_name" & ":" & LDFileName) as string
do shell script "mkdir -p " & quoted form of POSIX path of
TheFinalFileString
tell application "Image Events"
launch
set this_image to open OneFile
scale this_image to size (decided_width as integer)
save this_image in file TheFinalFileString with icon
close this_image
end tell
set incrementprogress to incrementprogress + 1
update progress indicator ImageResizeProgress current value
incrementprogress
end repeat
end timeout
close progress indicator ImageResizeProgress
---EDN SCRIPT
Jay Louvion
Studio Casagrande
3, rue Müller-Brun
1208 Geneva
T+4122 840 3272
F+4122 840 3271
skypeme:
jaylouvion
www.studiocasagrande.com
_______________________________________________
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