Copying to a folder based on year

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Copying to a folder based on year 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
ddougan
 
Posts: 11
Joined: Wed Aug 22, 2012 5:12 pm

Re: Copying to a folder based on year 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?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Copying to a folder based on year 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
ddougan
 
Posts: 11
Joined: Wed Aug 22, 2012 5:12 pm


Return to Support