Re: Creating Zip file via Create Archive
Re: Creating Zip file via Create Archive
- Subject: Re: Creating Zip file via Create Archive
- From: Pat Cannon <email@hidden>
- Date: Mon, 23 Feb 2009 15:56:19 -0600
Here's the slightly-tested script I use:
on open theItems
set draggedCount to count theItems
set startMsg to "Hi!" & return & return & "This script will create a " & draggedCount & " 'zipped' archive files, one for each of the " & draggedCount & " items you just dragged onto it." & return & return & "It will NOT delete the original files."
if draggedCount > 1 then set startMsg to startMsg & return & return & "Be patient; this takes a while. There'll be a dialog box to let you know when we're finished."
display dialog startMsg buttons {"Cancel", "Yep. Cool."} default button 2 with icon 1
set doneCount to 0
repeat with thisAlias in theItems
set itemPath to quoted form of POSIX path of thisAlias
tell application "Finder"
set fileName to name of thisAlias
set theFolder to (container of thisAlias as alias)
set theFolderPPath to POSIX path of theFolder
end tell
set zipFile to quoted form of (theFolderPPath & fileName & ".zip")
do shell script "zip -r -j " & zipFile & " " & itemPath
try -- We don't need to say anything if there are no .DS_Store files
do shell script "zip -d " & zipFile & " '*.DS_Store'"
end try
set doneCount to doneCount + 1
end repeat
beep 2
set doneIcon to 1 -- script icon
set doneBtn to "Cool"
set doneMsg to "All Done!" & return & return & doneCount & " files zipped."
if doneCount ≠ draggedCount then
set doneIcon to 2 -- alert triangle
set doneMsg to (doneCount as text) & " files were zipped." & return & return & "However, I see you dragged " & draggedCount & " items… I don't know what the story is with that. Sorry."
set doneBtn to "Whatever"
end if
activate
beep 3
display dialog doneMsg buttons {"Cool"} default button 1 with icon doneIcon
end open
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden