Re: Automate zip archives
Re: Automate zip archives
- Subject: Re: Automate zip archives
- From: Nigel Garvey <email@hidden>
- Date: Fri, 10 Nov 2000 00:14:53 +0000
Peter Mathiessen wrote on Thu, 09 Nov 2000 13:05:42 +0100:
>
I have made a script that takes a bunch of files and zip them in different
>
archives. The problem I have is it will not work properly, Zipit crashes all
>
the time. I have the script that Nigel wrote and that one works! What is
>
wrong?
>
>
My script:
>
>
tell application "Finder"
>
-- filecount
>
set countfolder to alias "Macintosh HD:count-folder:"
>
set foldercount to the count of every item of countfolder
>
if foldercount 1 then
>
-- flytt
>
set searchFolder to alias "Macintosh HD:count-folder:"
>
set myList to list folder searchFolder without invisibles
>
repeat with myFilename in every item in myList
>
set myFile to alias ("Macintosh HD:count-folder:" & myFilename)
>
move myFile to folder "zip-folder" of startup disk with
>
replacing
>
>
set searchFolder to alias "Macintosh HD:zip-folder:"
>
set myList to list folder searchFolder without invisibles
>
repeat with myFilename in every item in myList
>
set myFile to alias ("Macintosh HD:zip-folder:" &
>
myFilename)
>
tell application "ZipIt"
>
activate
>
make new window
>
add file ("Macintosh HD:zip-folder:" & myFilename)
>
compress file ("Macintosh HD:zip-folder:" & myFilename)
>
>
-- Zipit crashes here!
>
>
close the front window
>
end tell
>
end repeat
>
end repeat
>
end if
>
end tell
I don't know why ZipIt's crashing, but you mostly don't need the Finder
and there's an unnecessary inner loop in the script. The following works
OK as far as I've been able to test it:
tell application "ZipIt" to activate -- once only
set searchFolder to "Macintosh HD:count-folder:"
set myList to list folder alias searchFolder without invisibles
-- Nothing will happen at all if the folder's empty
repeat with myFilename in every item in myList
set myFile to alias (searchFolder & myFilename)
tell application "ZipIt"
make new window
add myFile
-- ZipIt saves with replacing anyway
compress file ("Macintosh HD:zip-folder:" & myFilename)
close the front window
end tell
end repeat
tell application "Finder" to delete every item of folder searchFolder
NG