Information Technology Reference
In-Depth Information
4.
In the main text area beneath the Run AppleScript heading, delete the
purple text that's already there, and type the following (or copy and paste
if you're reading the ebook):
ON RUN {FILELIST}
REPEAT WITH SINGLEFILE IN FILELIST
SET FILEPATH TO QUOTED FORM OF (POSIX PATH OF SINGLEFILE)
TELL APPLICATION "FINDER"
SET FILENAME TO NAME OF SINGLEFILE
SET PARENTFOLDER TO POSIX PATH OF (CONTAINER OF SINGLEFILE AS ALIAS)
END TELL
SET ZIPNAME TO QUOTED FORM OF (PARENTFOLDER & FILENAME & ".ZIP")
TELL APPLICATION "SYSTEM EVENTS"
ACTIVATE
DISPLAY DIALOG "ENTER PASSWORD" DEFAULT ANSWER "" WITH HIDDEN ANSWER
SET THE PASSWD TO TEXT RETURNED OF THE RESULT
END TELL
SET CMD TO "ZIP -P " & PASSWD & " -R " & ZIPNAME & " " & FILEPATH & " -X
*.DS_STORE"
DO SHELL SCRIPT CMD
END REPEAT
END RUN
5.
Click the icon representing a hammer above the textbox. This will check
the code to make sure it's correct. If it isn't, the error will be highlighted.
If it's fine, the code will be reformatted neatly, but you can ignore this—
it has no bearing on whether the script works.
6.
Click File→Save to save your new service. There's no need to choose a
destination, but for the filename type COMPRESSWITHPASSWORD .
7.
Once done, close the Automator window.
You can test your new service immediately by right-clicking any file or folder
in a Finder window or on the desktop and selecting Compress with Password
at the bottom of the menu that appears (you might have to click Services→
Compress with Password). A dialog box will appear where you can type the
password you'd like to use to protect the zip file you're about to create.
Note that when you unzip your password-protected file, it will always be in
a USERS folder and then a folder named after your username. This is because
of a limitation of the ZIP command.
To remove your service in the future, open a Finder window, and hit
SHIFT + COMMAND + G . Then type ~/LIBRARY/SERVICES , and click Go. Then drag the Com-
press with Password file to the trash and log out and back in again.
 
 
Search WWH ::




Custom Search