title: Applescript to sort files into folder based on British financial year
body: <p>I'm looking for way to move files based on UK financial year (runs from 6th April -5th April).
  Files are named in pattern as</p>
  <pre><code>2014-08-26_Asda_lunch.pdf
  2016-03-20_Tesco_sationary.pdf
  </code></pre>
  <p>The File needs to be moved to folders which are named, and so on</p>
  <pre><code>FY 2014-15
  FY 2015-16
  </code></pre>
  <p>Just wondering if applescript/ shell script or automator action would help to achieve this. Also interface with hazel wud be even better</p>
  <p>Thanks in advance
  I have tried to modify the script</p>
  <p>My first aim is get month right, then wud try dates;
  the Output for Script
  File 2019-07-26_Tesco_stationary -&gt; FY 2020 ( expected FY 2019-20)
  File 2019-03-15_Sainsbury -&gt; FY 2019 ( expected FY 2018-19)
  Please advise, also any pointers to add date in sorting wud be helpful
  Thank you</p>
  <pre><code>set savedDelimiters to AppleScript's text item delimiters
  set AppleScript's text item delimiters to {&quot;-&quot;}
  
  tell application &quot;Finder&quot;
     set filename to name of theFile
  end tell
  
  set expenseYear to (first text item of filename) as number
  set expenseMonth to (second text item of filename) as number
  set expenseDate to (third text item of filename) as number
  
  -- Get the last two characters of the Year
  set AppleScript's text item delimiters to savedDelimiters
  set lastTwoCharactersOfYear to (characters 3 thru 4 of (expenseYear as text))
  set RoundedExpYear to (lastTwoCharactersOfYear as text) as number
  
  
  if expenseMonth ≥ 4 then
     set LongString to expenseYear
     set ShortString to RoundedExpYear + 1
  else
     set LongString to expenseYear - 1
     set ShortString to RoundedExpYear
  end if
  
  
  set returnText to &quot;FY&quot; &amp; &quot; &quot; &amp; LongString &amp; &quot;-&quot; &amp; ShortString
  
  </code></pre>