Use AppleScript to Duplicate a File to a Different Folder with a New Name - duplicates

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.

The problem is the Finder doesn't support POSIX paths (slash separated).
Either you convert everything to HFS paths (colon separated) with POSIX file or you use HFS paths anyway.
This is the HFS path version which specifies the base folder "Finances" with a relative path to
set financesFolder to (path to documents folder as text) & "Finances:"
set BudgetReportFile to financesFolder & "Budget Reports:2020-05-01 April 2020.xlsm"
set StepsFolderPath to financesFolder & "Statements - Bank And Credit Card CSVs:2020-05-01 April 2020 Report:Steps:"
set BudgetReportStepName to "2020-05-01 April 2020 BEFORE STEP 01.xlsm"
tell application "Finder"
set duplicatedFile to duplicate file BudgetReportFile to folder StepsFolderPath
set name of duplicatedFile to BudgetReportStepName
end tell

Related

How do I direct autosys log files to dated folders

In my autosys jil (Windows), I have logging set up like this:
std_out_file: <servername>\autosys_log\%AUTO_JOB_NAME%-%AUTORUN%.std.out
I want to add the current date to the path, so e.g. for today that would be:
std_out_file: <servername>\autosys_log\2022-11-04\%AUTO_JOB_NAME%-%AUTORUN%.std.out
How can I get that to work? I need some way of dynamically inserting the current date in the output path.

Data factory copy based off last high water mark value (Dynamic date)

I'm currently working on a project where I need the data factory pipeline to copy based off the last run date.
The process breakdown....
Data is ingested into a storage account
The data ingested is in the directory format topic/yyyy/mm/dd i.e., multiple files being brought in a single directory hence it's files are partitioned by date which looks like this day format and month and year etc
The process currently filters based on the last high water mark date which updates each time the pipeline is run and triggers daily at 4am, once the copy is successful, a set variable increases the high-water mark value by 1 (I.e., one day), though files are not brought over on the weekends (this is the problem)
The date value (HWM) will not increase if no files are brought over and will continue to loop through the same date.
How to I get the pipeline to increase or look for the next file in that directory given that I use the HWV as the directory to the file, copy and update the HWM value only when completed dynamically. Current update logic
current lookup of HWV lookup and directory path to copy files
Instead of adding 1 to last high water mark value, we can try to update current UTC as watermark value. So that, even when pipeline is not triggered data will be copied to the correct destination folder. I have tried to repro in my environment and below is the approach.
Watermark table is taken initially with watermark value as '1970-01-01'.
This table is referred in the Lookup Activity.
Copy data activity is added and in source, query is given as
select * from tab1 where lastmodified > '#{activity('Lookup1').output.firstRow.watermark_value}'
In Sink, Blob storage is taken. In order to have folder structure as year/month/day,
#concat(formatDateTime(utcnow(),'yyyy'),'/', formatDateTime(utcnow(),'mm'),'/',formatDateTime(utcnow(),'dd'))
is given in folder path.
File is copied as in below path.
Once file is copied, Watermark value is updated with the current UTC time.
update watermark_table
set
watermark_value='#{formatDateTime(utcnow(),'yyyy-MM-dd')}'
where tab_name='tab1'
When pipeline is triggered next day, data will be copied from the watermark value and once file is copied, value of current UTC is updated as watermark value.
I think reading the post a couple of time , what I understood is
You already have a water mark logic .
On the weekend when there are NO files in the folder , the current logic does NOT increment the watermark and so you are facing issues .
If I understand the ask correctly . please use the #dayOfWeek() function . Add a If statement and let the current logic only execute when the day of the week is Monday(2)-Friday(6) .
https://learn.microsoft.com/en-us/azure/data-factory/data-flow-expressions-usage#dayofweek

Difference between File identifier and File name in File information list of MS Access database engine updates

I was going through July 5, 2022, update for Office 2016 (KB5002226) and I found that the file identifier and file name are different in the case of Acacedao.dll under the file information section.
Can I please know the difference between these two?
Update: It does not seem like a typo as Acedao is also mentioned on 3rd number

SSIS-Variable File Name

I have a folder in which every month I will put a single excel file with name (depending on the month) like 'Jun file', 'Jul file', 'Aug file' and others. I want to move this file from folder to Sql database and form the table of the same name, that is 'Jun file'(if it is the June Month's file).
I am trying to do it through SSIS by forming the variable but I am unable to do it. How should I create the variable for this varying file name.

How to select dynamical every month different source folder in SSIS

Scenario : Actual i want to see that one when Sep 6 only data load for source folder sep6 and tomorrow SEP 7 then data load form SEP 7 folder only then day after tomorrow SEP 8 mean data load from sep8 folder only but how ?????
I would do this by populating a variable from a C# script task. You can generate date/time strings very easily in a script task. E.g.:
Dts.Variables["User::FirstThreeCharsOfMonthNameUpper"].Value = DateTime.Now.ToString("MMM").ToUpper();