I'm a total newbie on Automator and Scripting… I have read a lot of answers to problems a bit similar to mine, but I don't succeed to adapt with Automator + AppleScript.
Here is what I want to do:
When I download a file to a directory /Volumes/Macboot /Downloads
, (yes there is a space in the HDD's name), e.g. statement_EUR_2020-05-01_2020-05-31.pdf
.
I verify if the file is with extension pdf + it contains an IBAN + the name contains "statement".
If the file corresponds, I want to verify the year and month in the name and move it accordingly to the good Google Drive folder:
/Volumes/Macboot /Travail en cours/Google
Drive/Company/Comptabilité/2020/05/Compte Transferwise 1/
With help from @Solar Mike, here is what I'm attempting:
What I am doing without success right now:
on run {input, parameters}
tell application "Finder"
activate
set theFile to input as text
set copyFile to input as alias
set yearName to ((characters 34 thru -1 of theFile) as string) --trim first 35
set yearName to ((characters 1 thru -22 of yearName) as string) --trim last 23
set monthName to ((characters 39 thru -1 of theFile) as string)
set monthName to ((characters 1 thru -19 of monthName) as string)
set destinationFolder to ("Macboot :Travail en cours:Google Drive:Company:Comptabilité:" & yearName & ":" & monthName & ":Compte Transferwise 1:Relevé PDF + fichier CSV:" as alias)
copy copyFile to (destinationFolder)
end tell
end run
No error… but no copied file.
yearName is good, as is monthName and destinationFolder, but perhaps I don't use the good method to copy?
Best Answer
I used this: