【发布时间】:2014-04-30 13:14:05
【问题描述】:
我正在尝试使用 applescript 将文件夹复制到我的桌面,对其进行压缩,然后将 .zip 文件移动到其他位置,但我无法让压缩部分工作。
我到处寻找在 applescript 中压缩文件/文件夹的方法,但我不知道自己做错了什么,但没有一个对我有用。
我也宁愿不必选择复制后的文件夹和压缩后的文件夹,但我想我会留下它们直到压缩修复。
任何帮助都将不胜感激。
这是我的代码:(在 djbazziewazzie 的帮助下更新)
set workspace to (path to desktop as text) --"Users:produser:Desktop"
tell application "Finder"
display dialog "Select a folder to be zipped"
set inputFolder to choose folder
set inputFolderProperties to properties of inputFolder
set inputFolderName to name of inputFolder
duplicate inputFolder to workspace with properties --copy input folder to workspace
{name:inputFolderName} --keep the same name
--set copiedFile to (workspace & inputFolderName)
display dialog "Select the folders desktop copy"
set copiedFile to choose folder --select the file copy thats on the workspace
tell current application
set qpp to quoted form of POSIX path of copiedFile
do shell script "zip -r " & qpp & ".zip " & qpp -- zips the file (or not...)
end tell
display dialog "Select the .zip file" --select the new .zip file
set zipFile to choose file
display dialog "Select the output folder"
set outputFolder to choose folder --moves zipped file
move zipFile to outputFolder
end tell
【问题讨论】:
标签: macos shell zip applescript