【发布时间】:2020-05-03 15:22:53
【问题描述】:
我正在尝试将文件复制到指定文件夹,但出现错误:
错误“Finder 出错:无法设置文件\”/Users/Andrew/Documents/Finances/Statements - Bank And Credit Card CSVs/2020-05-01 April 2020 Report/Steps/2020-05-01 2020 年 4 月在步骤 01.xlsm\" 之前归档 \"/Users/Andrew/Documents/Finances/Budget Reports/2020-05-01 April 2020.xlsm\"。"编号 -10006 来自文件“/Users/Andrew/Documents/Finances/Statements - Bank And Credit Card CSVs/2020-05-01 April 2020 Report/Steps/2020-05-01 April 2020 BEFORE STEP 01.xlsm”
我必须使用 AppleScript,因为我是从 VBA 中启动脚本。确定 3 个变量的 AppleScript 部分按预期工作。为简洁起见,代码如下所示:
DuplicateFileToStepsFolder("/Users/Andrew/Documents/Finances/Budget Reports/2020-05-01 April 2020.xlsm!/Users/Andrew/Documents/Finances/Statements - Bank And Credit Card CSVs/2020-05-01 April 2020 Report/Steps!BEFORE STEP 01")
on DuplicateFileToStepsFolder(ReportAndStepsPaths)
--code to split ReportAndStepsPaths into separate strings
set BudgetReportPath to "/Users/Andrew/Documents/Finances/Budget Reports/2020-05-01 April 2020.xlsm" --this is the file i want to duplicate
set StepsFolderPath to "/Users/Andrew/Documents/Finances/Statements - Bank And Credit Card CSVs/2020-05-01 April 2020 Report/Steps" --this is the directory I want to duplicate (or copy and move to)
set BudgetReportStepPath to "/Users/Andrew/Documents/Finances/Statements - Bank And Credit Card CSVs/2020-05-01 April 2020 Report/Steps/2020-05-01 April 2020 BEFORE STEP 01.xlsm" --this is the new file name
tell application "Finder" to duplicate file BudgetReportPath to folder StepsFolderPath
--line to rename the moved file would go here
end DuplicateFileToStepsFolder
复制、移动和重命名也可以解决我的问题。我还没有试图弄清楚重命名行。我确信也没有文件名冲突。
【问题讨论】:
标签: duplicates applescript move