I am attempting to duplicate a file to a specified folder but I get an error:
error "Finder got an error: Can’t set file \"/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\" to file \"/Users/Andrew/Documents/Finances/Budget Reports/2020-05-01 April 2020.xlsm\"." number -10006 from file "/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"
I have to use AppleScript because I am initiating the script from within VBA. the part of the AppleScript that determines the 3 variables works as intended. For brevity the code looks like this:
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
Copy, move and rename would also solve my problem. I haven't tried to figure out the rename line. I am sure that there are no file name collisions either.