help-- zip folder automator

Joined
May 27, 2007
Messages
3
Reaction score
0
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..:confused:

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!
 

Ric

Joined
May 14, 2004
Messages
4,260
Reaction score
5
Hi there and welcome !

I'll have a look at your code tonight...

...lots to catch up on !

regards

Ric
 

Ric

Joined
May 14, 2004
Messages
4,260
Reaction score
5
Hi there,

sorry for our sloow response !

First, why do this via terminal...or via Automator or via AppleScript...

Can you not just right click (or hold down the control key) and click the folder that you want to zip and select 'Archive..'

create-Archive.jpg


Regards

Ric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top