Filing into financial year folders

I need to automate filing pdfs into folders based on financial years (July to June) not calendar years

is there any way to setup a series of files or automations for this?

As there’s no such feature, the only possibility is to file them using your own scripts (either on demand or automatically via smart rules).

I don’t have any advice about automation other than using the classify function. (I do use automation but it’s been cribbed from other experts on this forum so I don’t feel it is my place to offer any actual advice)

There are scripts available to pull names, dates, and amounts from PDFs and put that data where you need it within each documents metadata

My folders are categorized by the various utilities, on-site labour charges, supplies, collected fees etc and not divided by months so maybe the following won’t work for you. Either way…

I have one small project that’s September to August fiscal and for that one, in August, I add all the template folders for the coming new year and then on Sept 1 I hide the outgoing years folders from Classification and start Classifying to the new folders.
This is admittedly a very small fiscal project with 5 to 10 receipts per month but it’s working fairly well for my needs.

1 Like

Thank you very much for these replies

For this issue I have files named “Feb-23” “Mar-23”

For “month-year” syntax

Is there any way to file these based on the year eg somehow to search for the string “-23” in file name and interpret it as the year 2023 then file it in the folder “2023” (then for 2024 etc or any year in the future

I have tried searching this and for other similar issues and I’m not a programmer, so I’d be really grateful if someone could step me through it

Are you interested in an applescript solution?
I use a script to assist with processing inbox entries;
such things as filenames, filing, tags, …

Personally, I would be using tags instead of groups (folders)

I have files named “Feb-23” “Mar-23”

I include the date in filenames; my standard is yyyy-mm-dd

1 Like

So you have all your documents for February 2023 in a single file? Or do you have several files whose names contain “Feb-23”? This convention is, btw, nice for reading but not so good for automating. If you were using a sortable document format like 2023-01-04 (ISO date, not US!), you could very easily sort your files by name and see which one belongs into which FY.

What you could do is to define a smart group like so

It will then organize all files whose names match “Jan-”, “Feb-”, or “Mar-” in the smart group “Monate” (well, “1st quarter” might be a better name).

But your original question was about a fiscal year running from July to June, crossing the calendar year boundary. I don’t see a simple one-step solution for that. What I would try is writing a script that assigns a tag to the files according to the fiscal year and then use smart groups for each fiscal year.

This educational script is written in JavaScript and can be added to a smart rule as “internal script”. It assigns the tag ‘FYXXXX’ to the records, where XXXX is the 4-digit fiscal year.

// Months for first half year
const firstHalf = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'];
// Months for second half year
const secondHalf = ['Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// Concatenate all month names to an alternation for the following RE
const monthAlternates = firstHalf.concat(secondHalf).join('|');
// Build the RE to match the names:
// (Jan|Feb|Mar…)-(\d\d)
// First capturing group: month name
// Second capturing group: 2-digit year
const nameRE = new RegExp(`(${monthAlternates})-(\\d\\d)`);

function performsmartrule(records) {
  /* Loop over all records selected by the smart rule */
  records.forEach(r => {
     /* Match the record's name against the RE */
     const match = r.name().match(nameRE);
     if (match) {
       /* Extract the capturing groups from the match */
       const month = match[1];
       let year = +match[2] + 2000; /* use + to force number */
       /* If the month is in the 2nd half, it belongs to the next fiscal year */
       if (secondHalf.includes(month)) {
         year++;
       }
       /* Set the tag 'FY20xx' for this record */
       r.tags = r.tags().concat(`FY${year}`);
      }
  })
}

You could then use the tag groups for FY2023 etc. to see all documents belonging to that fiscal year. Or define a smart group that assembles all documents with the tag ‘FY2023’ etc.

1 Like

Thankyou so much for the detailed reply!

to be a bit clearer - each month files with this naming structure are issued by my accountant for monthly business activity statements.

I am going to play with this script this weekend. I think there are other users that could really benefit from this too.