title: Mac Automater: from a string, get a file
body: <p>I'm trying to make a shortcut via an automater service that will move the selected file(s) up a directory. It goes as follows:</p>
  
  <ol>
  <li><p>Get Selected Finder Items</p></li>
  <li><p>Get Value of Variable <code>Path</code></p></li>
  <li><p>Run Applescript:</p>
  
  <pre><code>on join(someList, delimiter)
  set prevTIDs to AppleScript's text item delimiters
      set AppleScript's text item delimiters to delimiter
      set output to "" &amp; someList
      set AppleScript's text item delimiters to prevTIDs
      return output
  end join
  to split(someText, delimiter)
      set AppleScript's text item delimiters to delimiter
      set someText to someText's text items
      set AppleScript's text item delimiters to {""}
      return someText
  end split
  on run {input, parameters}
      set pathToMe to POSIX path of (item 1 of input as text)
      set newPath to split(pathToMe, "/")
      set revPath to reverse of newPath
      set restList to rest of revPath
      set restList to rest of restList
      set joinPath to join(reverse of restList, "/")
      set source to POSIX file joinPath
      return source
  end run
  </code></pre></li>
  <li><p>Set Value of Variable <code>Parent</code></p></li>
  <li><p>Move Finder Items To <code>Parent</code></p></li>
  </ol>
  
  <p>The Applescript parses the first file path in the <code>Path</code> in order to find the item's grandparent, returning it as a POSIX file string. The problem is that the "Move Finder" action only accepts Files/Folders. How can I select the target parent folder with the resulting string in order to pass it to the "Move Finder" action? </p>
  
  <p>Things I've tried:</p>
  
  <ul>
  <li>Using <code>mv</code> in a <code>Run Bash Script</code>: the <code>Run Applescript</code> action doesn't seem to return anything to the <code>Run Bash Script</code>; set to input as arguments, "$@" is always empty.</li>
  <li>Doing a <code>tell finder</code> in <code>Run Applescript</code>. No error or warning, just nothing happens.</li>
  <li>Manually setting the value of the <code>parent</code> variable. </li>
  </ul>
  
  <p>Thanks in advance! </p>