将目录(和子目录)中的每个 PDF 文件移动到另一个文件夹
我想将文件夹及其子文件夹内的每个 .pdf 文件移动到另一个文件夹。我尝试使用 AppleScript 执行此操作,但返回错误:
tell application "Finder"
set theFolder to path to downloads folder from user domain
set destFolder to choose folder
repeat with currentFolder in (every folder of theFolder)
move (every item of (currentFolder) that name extension is "pdf") to destFolder
end repeat
end tell
有人知道如何解决吗?
另外,有什么办法可以用 shell 脚本做同样的事情吗?
I want to move every single .pdf file inside a folder an its subfolders to another folder. I'm trying to do this with AppleScript, but an error is returned:
tell application "Finder"
set theFolder to path to downloads folder from user domain
set destFolder to choose folder
repeat with currentFolder in (every folder of theFolder)
move (every item of (currentFolder) that name extension is "pdf") to destFolder
end repeat
end tell
Does anyone know how to solve it?
Also, is there any way to do the same with shell script?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下将递归搜索并将所有 *.pdf 文件移动到另一个文件夹。
The following will search recursively and move all the *.pdf files to another folder.
使用 CLI,rsync 是一个很好的选择。给定以下结构:
这将传输所有 PDF 和目录,不包括所有其他文件:
如果您不关心维护文件夹结构:
Using the CLI, rsync is an excellent option. Given this structure:
This will transfer all PDF's and directories, excluding all other files:
If you don't care about maintaing the folder structure:
这是一个 applescript 方法。在命令中使用“全部内容”还可以搜索子文件夹。
Here's an applescript method. Using "entire contents" in the command makes it also search subfolders.