forked from a4agarwal/dropzone-user-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZip Files.dropzone
executable file
·37 lines (29 loc) · 974 Bytes
/
Zip Files.dropzone
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/ruby
# Dropzone Destination Info
# Name: Zip Files
# Description: Zips up the dropped files or folders and places the zip file on the desktop.
# Handles: NSFilenamesPboardType
# Creator: Sergej Müller
# URL: http://ebiene.de
# IconURL: http://aptonic.com/destinations/icons/zip.png
def dragged
output = `./CocoaDialog standard-inputbox --title "New ZIP File" --e --informative-text "Enter name for new zip file (minus extension):"`
button, filename = output.split("\n")
if button == "2"
$dz.finish("Cancelled")
$dz.url(false)
return
end
if filename == nil
$dz.finish("Invalid Filename")
$dz.url(false)
return
end
desktop = ENV['HOME'] + '/Desktop'
zipfile = ZipFiles.zip($items, filename + ".zip")
zipfile = zipfile[1,zipfile.length - 2]
system("zip -d #{zipfile} '__MACOSX*' '*.DS_Store' >& /dev/null")
Rsync.do_copy(zipfile.gsub(/ /, '\ '), desktop, true)
$dz.finish("ZIP created")
$dz.url(false)
end