Sample Header Ad - 728x90

AppleScript for zipping folders does unexpected things

3 votes
1 answer
535 views
I compiled the following script to zip multiple folders with only their contents. (*So for instance, folder X containing files A, B and C will form a zip file containing A, B and C and not folder X as a parent.*) on run {input, parameters} tell application "Finder" set theItems to selection repeat with i from 1 to (count of theItems) set theItem to (item i of theItems) 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") do shell script "zip -jr " & zipFile & " " & itemPath delete (item i of theItems) end repeat end tell return input end run By testing it with a simple folder and a few random files, the script works fine. But when the folder contains a lot of files, the following error pops up: > 'zip warning: first full name: /Users/laurens/Desktop/Test folder/.DS_Store second full name: /Users/laurens/Desktop/Test folder/story_content/.DS_Store name in zip file repeated: .DS_Store this may be a result of using -j > > zip error: Invalid command arguments (cannot repeat names in zip > file)' enter image description here I checked the same folder on Windows (through Parallels), and I can't see any .DS_Store files, also I'm not sure why the script refers to those files instead of the folders... I'm not sure what to make of this.
Asked by LauLauPeet (41 rep)
May 2, 2022, 09:37 AM
Last activity: Jun 2, 2022, 09:47 AM