Hi All
I just want to know if anyone thinks it’s possible to do the following?
At root level I have a folder called “hires” inside this folder are folders 0001 - 1000.
Inside each folder are 1 or more jpg’s.
I would like to have another folder at root level called “zips”.
I would like to have the script scan the “hires” folder, and when it finds folders inside, using codes for folder names ie “0004, 0005 to 1000” it makes seperate zip files for each jpg contained in them.
Once the relevant zips are made, can the script replicate the folder code ie 0005, then proceed to store this folder and containing zip’s to a root level folder called “zips”!!!
(I’m using DropZip, to make the zip files).
Is this do-able??
As I don’t think it is by me!
TIA
wilse
Roland
October 18, 2004, 1:22pm
#2
Hi
This script uses the internal zip not DropZip. I dont know how to script “DropZip”
Cheers Roland
–Open this script in a new Script Editor window.
property sPath : “path:to:source:folder:”
property dPath : “path:to:destination:folder:”
tell application “Finder”
set folderList to every folder of folder sPath
repeat with oneFolder in folderList
set folderName to name of oneFolder
set itemList to every file of oneFolder
repeat with oneItem in itemList
set itemPath to oneItem as string
set itemPath to quoted form of POSIX path of itemPath
set itemName to (name of oneItem )
--[i][color=olive]this saves the zip with the file extension (name.jpg.zip)[/color][/i]
[b][color=blue]set[/color][/b] [color=green]savePath[/color] [b][color=blue]to[/color][/b] [color=blue]quoted form[/color] [b][color=blue]of[/color][/b] [color=blue]POSIX path[/color] [b][color=blue]of[/color][/b] [color=green]dPath[/color] & [color=green]folderName[/color] & "/" & [color=green]itemName[/color] & ".zip"
--[i][color=olive] this saves the zip without file extension (name.zip)[/color][/i]
--[i][color=olive]set fileExt to name extension of oneItem[/color][/i]
--[i][color=olive]set extCount to (count of fileExt) + 1[/color][/i]
--[i][color=olive]set savePath to quoted form of POSIX path of dPath & folderName & "/" & text items -extCount thru 1 of itemName & "zip"[/color][/i]
[b][color=blue]try[/color][/b]
[color=blue]make[/color] [color=blue]folder[/color] [b][color=blue]in[/color][/b] [color=blue]folder[/color] [color=green]dPath[/color] [color=blue]with properties[/color] {[color=blue]name[/color]:[color=green]folderName[/color]}
[b][color=blue]end[/color][/b] [b][color=blue]try[/color][/b]
[color=blue]do shell script[/color] ("/usr/bin/ditto -c -k -rsrc --keepParent " & [color=green]itemPath[/color] & " " & [color=green]savePath[/color])
[b][color=blue]end[/color][/b] [b][color=blue]repeat[/color][/b]
[b][color=blue]end[/color][/b] [b][color=blue]repeat[/color][/b]
end tell
[This script was automatically tagged for color coded syntax by Convert Script to Markup Code ]
Hi Roland
Thanks very much for that, interestingly you commented in the script that
–this saves the zip with the file extension (name.jpg.zip)
Funnily enough, that’s exactly what I need!
I’ll load it up today and give it a go, where is the best place for me to learn the basics of Applescript, as I don’t think I could dream that up in a month of Sundays.
All the best
wilse
Hi again Roland
I’ve figured out how to set the path :oops:
And the script works! I’m not sure why I’m surprised (sorry to doubt your talents)
When I run the batch, I have found that it gives’ up after the 2nd folder, however the 3rd folder is made, but there is nothing in it?
I get “finder got an error: ditto: can’t archive multiple sources”
Sorry to trouble you more?
Can anyone shed any light on this, please?
Wilse :?: