首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >访问AppleScript中的文件夹

访问AppleScript中的文件夹
EN

Stack Overflow用户
提问于 2013-09-19 00:14:20
回答 3查看 727关注 0票数 1

对不起,AppleScripting完全是初学者。

我想做一件非常简单的事情,把文件从一个文件夹移到另一个文件夹。

代码语言:javascript
复制
tell application "Finder"

    set this_folder to "Users:chris.nicol:Movies:SmartConverter:"

    set this_list to every file of this_folder
    repeat with i in this_list
        --if i does not start with "x" then
        move i to "users:chris.nicol:music:itunes:itunes media:automatically add to itunes:"
        --end if
    end repeat
end tell

然而,我总是收到一个错误:

我尝试过不同的命令(计数、parentContainer等)在文件夹中,但是我得到了相同类型的错误。我试过不同格式的文件夹..。

  • 用户/chris.nicol/Movies/智能转换器/
  • 麦金塔HD:Users:chris.nicol:Movies:SmartConverter
  • 等。

对我做错了什么有什么想法吗?

谢谢你,克里斯

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-09-19 16:17:51

简单的提示..。如果您想要找到正确的路径,您应该使用此方法,并在结果字段中查找正确的路径。您将看到硬盘驱动器的名称,Macintosh,是必需的。注意,如果您想要文件的路径,也可以使用“选择文件”。

代码语言:javascript
复制
(choose folder) as text

接下来,您将看到的路径是一个字符串。Applescript将其视为字符串,而不是文件或文件夹的路径。因此,当您想要使用字符串作为路径时,必须将单词"file“或”文件夹“适当地放在前面,以使applescript正确地使用它。因此,您的脚本应该如下所示。请注意,move命令可以处理文件列表,因此不需要重复循环。

代码语言:javascript
复制
set this_folder to "Macintosh HD:Users:chris.nicol:Movies:SmartConverter:"
tell application "Finder"
    set this_list to every file of folder this_folder
    move this_list to folder "Macintosh HD:Users:chris.nicol:music:itunes:itunes media:automatically add to itunes:"
end tell
票数 2
EN

Stack Overflow用户

发布于 2013-09-19 00:58:24

尝试:

代码语言:javascript
复制
set thisFolder to (path to movies folder as text) & "SmartConverter"
set thatFolder to (path to music folder as text) & "itunes:itunes media:automatically add to itunes"

tell application "Finder" to move files of folder thisFolder to thatFolder
票数 1
EN

Stack Overflow用户

发布于 2013-09-19 00:24:41

您必须在其中一个文件夹中有一些不可见的或其他不可复制的文件。要么将类似without invisibles的内容添加到set this_folder行的末尾,要么完全摆脱循环,只需调用

代码语言:javascript
复制
move files of entire contents of this_folder to (the Add Automatically folder)
票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18884398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档