使用脚本从excel中的列表复制文件。脚本完成后,我需要“结果”文本

时间:2019-09-09 18:05:33

标签: applescript

我正在尝试查找和复制大量文件。我将它们列在Excel工作表中。列表是我包含的文件的文本字符串。我需要找到包含这些字符串的文件,并将它们复制到另一个位置。我可以用我拥有的代码来做到这一点。我需要的是一个日志文件或一些文件,其中显示了找到和复制了哪些文件以及没有找到哪些文件。

我已使用以下脚本尝试过此操作,但“ echo”未列出未找到哪些文件。

set theDirectory to quoted form of POSIX path of (choose folder with prompt "Select Search Directory")
set theDestination to quoted form of POSIX path of (choose folder with prompt "Select Directory to Copy Files")
tell application "Microsoft Excel"
    tell active sheet
        tell used range
            set rc to count of rows
        end tell
        set theList to get value of range ("A1:A" & rc) as list
        repeat with theItem in theList
            if contents of theItem is not {""} then
                try
                    do shell script "find " & theDirectory & " -iname '" & "*" & theItem & "*' -exec cp {} " & theDestination & " \\;"
                on error
                    do shell script "echo " & theDirectory & "/" & theItem & " does not exist >> ~/Desktop/error.txt"
                end try
            end if
        end repeat
    end tell
end tell

0 个答案:

没有答案