Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inclued Folders' Contents in the Zipped Archive #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -2,3 +2,5 @@ alfred-fileaction-zip
=====================

This simple [Alfred App](http://www.alfredapp.com/) workflow adds a file action which mimicks the Finder right-click action "Create Archive from ... items".

This fork adds functionality onto the original so that folders are included. In the original, while the actual folder itself got added to the Archive, the folder's contents did not.
9 changes: 8 additions & 1 deletion zip.py
Expand Up @@ -14,7 +14,14 @@ def zip(files):
z.write(file, os.path.join(ARCHIVE, file.replace(path, u'', 1)))
return zipfile

files = alfred.args()[0].split('\t')
files_and_folders = alfred.args()[0].split('\t')
files = []
for file in files_and_folders:
if (os.path.isdir(file)):
files_and_folders.extend(map(lambda x: file + '/' + x, os.listdir(file)))
else:
files.append(file)

try:
zipfile = zip(files)
except Exception as e:
Expand Down