Hi, I was getting tired of going to the terminal to zip folders so I made an automator script so all i had to do was right click the folder and select "zip this folder" and it would be done! We'll I'm not too keen at applescript and it only works sometimes..
Sometimes it gives me an error,and when it does work, when unzipping it turnes out it ziped my USERS folder, but not the whole ting
only the original folder is there, but it put it in a whole bunch of folders:
Users>Desktop>folder
Right now this is the automator script:
1: Get Selected Finder items
Files/Folders
v
Anything
2: Run applescript
As I said not too good at applescript so I had to use a lot of ../ which i think is causing the problem. Any help would be great!
Sometimes it gives me an error,and when it does work, when unzipping it turnes out it ziped my USERS folder, but not the whole ting
only the original folder is there, but it put it in a whole bunch of folders:
Users>Desktop>folder
Right now this is the automator script:
1: Get Selected Finder items
Files/Folders
v
Anything
2: Run applescript
Code:
--I stole this method from apple:
--http://www.apple.com/applescript/guidebook/sbrt/pgs/sbrt.07.htm
--thanks for this handy script apple!
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
--Start the actual run method
on run {vfolder}
set vfolder to vfolder as string
set verror to false
set vfile to ""
tell application "Finder"
if folder vfolder exists then
set vfile to name of folder vfolder
else
set verror to true
end if
end tell
set vfolder to replace_chars(replace_chars(vfolder, "Macintosh HD:", ""), ":", "/")
if verror = false then
do shell script ¬
("zip -r ../../" & vfolder & "../" & vfile & ".zip ../../" & vfolder)
else
display dialog "There was an error zipping the file:
\"" & vfolder & "\"" buttons {"Ok"}
end if
end run
As I said not too good at applescript so I had to use a lot of ../ which i think is causing the problem. Any help would be great!