LONG STORY SHORT: I created a script a while back that uses quite a few different apps to accomplish it’s task. Now, I am trying to remove any software from the script that could be done with the OS and/or shell scripts. (I’m thinking it ought to simplify things!) I originally used Stuffit to Zip files but, instead, I want to use a shell command I found somewhere a while back to simplify the script.
Here is the segment of script I’m trying to work on that will ultimately go into the larger script. (It works sometimes.):
tell application "Finder" set this_folder to choose folder set only_folders to every folder of this_folder -- Don't need aliases here. The Finder understands its own references. repeat with i in only_folders set theName to name of i if length of theName is greater than 20 then set theName to text 1 through 20 of theName set the name of i to theName end if end repeat set only_folders to every folder of this_folder repeat with e in only_folders set theItem to e as alias set itemPath to (quoted form of POSIX path of theItem) set fileName to name of theItem set theFolder to POSIX path of (container of theItem as alias) set zipFile to quoted form of (theFolder & fileName & ".zip") try do shell script "zip -r -j " & zipFile & " " & itemPath -- delay 1 -- this may be needed (and adjusted) for larger folders? on error -- We don't need to say anything if there are no .DS_Store files do shell script "zip -d " & zipFile & " '*.DS_Store'" end try end repeat end tell
The error I get about half of the time has to do with “.DS_Store” files. Usually, this occurs whenever I am Zipping a folder that contains other folders within it. I get an error that reads:
[b]zip warning: first full name: /Users/Account/Documents/Folder/Folder/FolderName/Fonts/.DS_Store
zip warning: first full name: /Users/Account/Documents/Folder/Folder/FolderName/.DS_Store
zip warning: name in zip file repeated: .DS_Store
zip error: Invalid command arguments (cannot repeat names in zip file)[/b]
Ideally, this little segment of script should Zip every folder inside of the chosen folder. For my purposes, the folders it will zip are collected artwork folders created by software such as FlightCheck or ArtFiles. Within each of these “collected folders” are subfolders for “fonts” and “images”. It seems that the shell is having a hard time with some of the invisible “.DS_Store” files assigned to these folders.
The script I have put together here seems to have an extra shell command that ought to deal with “.DS_Store” files but I’m not sure how to make it work (or even know if this is the proper solution for my issue). Any suggestions appreciated! (Please comment out any suggestions.)