title: Automator - find and move most recent file in filtered list
body: <p>I'm trying to use Automator to </p>
  
  <ol>
  <li>get a filtered list of files in a folder that are more than 30 days old (ok)</li>
  <li>move the most recent of those (if there are any) to an existing subfolder </li>
  <li>trash the others. </li>
  </ol>
  
  <p>Step 1 is easy enough, but I haven't been able to find a way to do step 2 -- select and move the most recent of the filtered set. </p>
  
  <p>The outcome would be: if the workflow is scheduled once a month, then the subfolder will contain one file per month, &amp; the parent folder will contain only files less than 31 days old</p>
  
  <p>Is there a way to do that? </p>
  
  <p>UPDATE 
  I tried adding a shell script to the automator workflow </p>
  
  <pre><code>fn=$(ls -t | head -n1)
  mv -f -- "$fn" ./&lt;subdirectory&gt;/
  </code></pre>
  
  <p>But am having trouble with the path in the second line. </p>