Have Automator add original path to Spotlight Comment for a file when moving to the trash


Is there a way to add the original path of a document as a Spotlight comment in Mountain Lion?

I have created an automator workflow that automatically adds the Timestamp and user when a file is moved to trash. It also touches the file, so that its modified date becomes when it was moved (unless of course it is subsequently changed). This way I can find files I deleted by accident more easily. If I also have the original path to the document then I can put it back from where it came (for example if I deleted from search results).

Best Answer

I would just use Applescript to do it in a Run Applescript Action

on run {input, parameters}
    set theDate to do shell script "date +%Y_%m_%d_%H:%M:%S"
    tell application "Finder"

        repeat with thisfile in input
            set theComment to theDate & return & POSIX path of thisfile
            set comment of (thisfile as alias) to theComment

        return input
    end tell

end run

This sets the date stamp and path. It should be simple to add your touch and delete code to this.

enter image description here