Re: What's wrong with this call to zip?
Re: What's wrong with this call to zip?
- Subject: Re: What's wrong with this call to zip?
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 27 Feb 2008 10:33:37 -0500
The first parameter to zip tells it where to put the archive file.
Since "do shell script" doesn't tell you what the current working
directory is, it's a good idea to make it a full path; since we're in
shell-land, that needs to be a POSIX path.
The remaining parameters to zip serve two different purposes, which is
probably why the behavior is surprising you. First, they tell zip
where to find the files to put into the archive. But they also tell
it what to name the files *within* the archive. Those names determine
where the files go when the archive is extracted. If you specify the
full path to a file, the name in the archive will be the full path,
and that's what will be extracted.
For instance, say you have a file named "ZipMe.txt" on your desktop
that you want to put into an archive named "ZipMe.zip", also on your
desktop:
set deskPath to quoted form of POSIX path of ¬
path to desktop
set archiveName to quoted form of "ZipMe.zip"
set fileName to quoted form of "ZipMe.txt"
If you do this:
do shell script ¬
("cd " & deskPath & "; " & ¬
"zip " & archiveName & " " & fileName)
you will get what you want. If you do this:
set archivePath to deskPath & archiveName
set filePath to deskPath & fileName
do shell script "zip " & archivePath & " " & filePath
Then you will still get a ZipMe.zip on your desktop, with the same
file inside it, but that file will be named something like
"/Users/Yvan/Desktop/ZipMe.txt", which means when someone unzips the
file they'll get a "Users" folder with an "Yvan" subfolder with a
"Desktop" subfolder - which is probably not what you want.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden