• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Zip and keep folder structure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Zip and keep folder structure


  • Subject: Zip and keep folder structure
  • From: Rosemary Cantrell <email@hidden>
  • Date: Mon, 7 Dec 2009 10:42:01 -0600

You guys helped me with a script a while back where I wanted to zip
single PDFs using a drop app and this works perfect for the files I
originally intended it for.
Now I want to use it for a little wider use and am running in this issue.

I collect my InDesign file and it puts all the fonts in a folder and
all the images in a folder and then the InDesign file loose in the
package folder. Then I use the script it creates a zip file (yay) but
then I uncompress -- all of the items go into one directory instead of
having that fonts folder separate and the images folder separate.

If I right click and send to archive in OSX it retains the folder
hierarchy.  So what is the script doing differently than what the OS
is?

Any help is greatly appreciated.

Here is the script as it's used now...

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
               if fileName contains "." then
                       set oldTID to AppleScript's text item delimiters
                       set AppleScript's text item delimiters to "."
                       set nameItems to text items of fileName
                       set AppleScript's text item delimiters to "_"
                       set fileName to nameItems as text
                       set AppleScript's text item delimiters to oldTID
               end if
               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

  • Follow-Ups:
    • Re: Zip and keep folder structure
      • From: Roger Howard <email@hidden>
    • RE: Zip and keep folder structure
      • From: "Dennis Cox" <email@hidden>
  • Prev by Date: Re: Is it possible to multi-thread do shell script?
  • Next by Date: Getting list of installed TTS voices
  • Previous by thread: Trying to modify Menu Extras
  • Next by thread: RE: Zip and keep folder structure
  • Index(es):
    • Date
    • Thread