Page 1 of 1

Copying to a folder based on year

PostPosted: Sat Nov 13, 2021 7:12 pm
by ddougan
I've created a rule that renames files based on content, including the year and month. I want to copy these files to a network folder into a subfolder that is named for the year in the filename.

After doing a fair bit of digging, I came up with this embedded script:

Code: Select all
set report_year to item 1 of inputAttributes

tell application "Finder"
   try
      set thisPath to "/Volumes/Private/Scanned CHEQUES/1 MONTHLY CHEQUE SUMMARIES/"
      set fullPath to thisPath & report_year as text
      if not (exists fullPath) then
         set y to make new folder at thisPath with properties {name:report_year}
      end if
      activate
      open y
      copy file theFile to folder fullPath
   end try
end tell


When I run it, I'm getting AppleScript time-out errors in the log. In the testing I'm doing, the folder actually exists for the year in question.

I'd appreciate feedback on where I'm going wrong.


Thanks,

Des

Re: Copying to a folder based on year

PostPosted: Mon Nov 15, 2021 11:26 am
by Mr_Noodle
Is there a reason why you aren't using Hazel's Copy and Sort into subfolder actions to do this?

Re: Copying to a folder based on year

PostPosted: Mon Nov 15, 2021 6:39 pm
by ddougan
Mr_Noodle wrote:Is there a reason why you aren't using Hazel's Copy and Sort into subfolder actions to do this?


I guess because I didn’t quite understand the sort into subfolder functionality - which does exactly what I want... I've tried it and it works for me.

Thanks, Paul.


Des