【问题标题】:Applescript copying files from mounted disk to folder on main diskApplescript将文件从挂载磁盘复制到主磁盘上的文件夹
【发布时间】:2013-06-18 21:59:54
【问题描述】:

这是我第一次尝试 AppleScript。我正在尝试使用未知数量的文件获取已知安装的设备(在本例中为 Olympus 录音机)并将它们从设备复制到 Macintosh HD 上的特定文件夹。我编写了一个简短的脚本,告诉 finder 检查设备和文件夹,然后将文件夹中文件的名称放入变量中。然后 foreach 循环遍历列表并应该将文件复制到它们的最终休息位置...结果是错误“无法获取...的 Current_File” 其中 Current_File 是 File_List 变量的当前迭代。

这是脚本(注释掉的行是尝试隔离错误): *

tell application "Finder"
    if folder "DSS_FLDA" of disk "Untitled" exists then
        set File_List to files of folder "DSS_FLDA" of disk "Untitled"
        local Current_file
        foreach(Current_file in File_List)
            #Print Current_File
            copy file Current_file to folder "User:wt:DSSPlayer:Message:FolderA" of startup disk
    else
        return 0
    end if

    #first item of folder "DSS_FLDA" of disk "Untitled"
end tell

*

任何对 Applescript 有更多经验的人都可以为我指明一个更有成效的方向吗?

谢谢, 丹尼尔。

【问题讨论】:

  • 您正在寻找重复的命令。 stackoverflow.com/questions/17094205/…
  • 这甚至与您遍历列表或评论混合语言的方式不相近
  • 您实际上可以使用 # 来注释 AppleScript。
  • 嘿,这样你就可以每天学习新的东西了,他们什么时候实现的@adayzdone
  • 当有人向我指出时,我也有类似的反应! i.imgur.com/c515G7n.png

标签: applescript


【解决方案1】:

你可以使用重复的命令或者只是 cp:

tell application "Finder"
    try
        duplicate items of folder "DSS_FLDA" of disk "Untitled" to POSIX file "/Users/wt/DSSPlayer/Message/FolderA" replacing yes
    on error
        --
    end try
end tell
do shell script "[[ -e /Volumes/Untitled/DSS_FLDA ]] && cp /Volumes/Untitled/DSS_FLDA/ ~/DSSPlayer/Message/Folder"

【讨论】:

  • 感谢 Lauri,shell 脚本有效。下一步是弄清楚如何在设备对接时动态确定设备名称是什么,这样我就不必为每台机器重写脚本。我会让你知道结果如何;-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-10-17
  • 2019-08-28
  • 1970-01-01
  • 1970-01-01
  • 2020-11-27
  • 1970-01-01
  • 2016-02-20
相关资源
最近更新 更多