Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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).

share|improve this question
    
If you right click on most Trash items, there's Put Back option. Why can't you use that? –  Shane Hsu Feb 14 '13 at 17:08
    
Are you saying you already added the timestamp and user to the Spotlight comment and the only thing remaining is figuring out how to append the file's original path to the (presumably already existing) Spotlight comment? –  HairOfTheDog Feb 14 '13 at 22:23
    
@ShaneHsu - I found the Put Back option. It works fine for individual files that were deleted, but not if their parent folder was deleted (and Put Back isn't available for parent folders). Anyway, sometimes I might want to Put Back based on where the file was originally (e.g. I deleted a bunch of files out of a folder in one go and may want to restore only a few of them). –  dunxd Feb 15 '13 at 12:13
    
@HairOfTheDog - that's right - I've got everything else done already. –  dunxd Feb 15 '13 at 12:13

2 Answers 2

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

share|improve this answer
    
This looks very helpful in that it shows how to get the path of a file but I am using the Folder Action receives files and folders added to Trash. I already have a step which appends the timestamp and user that deleted the item to the Spotlight comment. How can I append the original path to this comment as a separate step? –  dunxd Feb 20 '13 at 19:49
    
I'll award the bounty to this, as it has probably set me in the right direction, but it hasn't really answered the question for me. –  dunxd Feb 21 '13 at 18:36
1  
I actually thought you were using the workflow/service to do the delete. It is important to put all relevant info in your questions. i.e you are using a Folder Action. AFAIK there is no way to find where the file came from after the move. You have to do that before the actual move and therefore before the folder action. Doing the delete via a service would enable you to do what you want. –  markhunte Feb 21 '13 at 21:06
    
In that case I'm not going to get much further with my project - I'm trying to get an automator workflow that will "fix" the trash functionality. I don't get this by creating a "special" way to move files to the trash. I guess what I have achieved so far allows me to find recently deleted items, and the Put Back functionality works at least some of the time. That'll do for now. Thanks for the assistance. –  dunxd Feb 22 '13 at 13:57

@dunxd The Trash in Mac OS X has an option enter image description here

@BenjaminDobson wrote a tool using Foundation API that when added to your Finder toolbar tells you the path of selected item.

You can explore adding this tool to your Automator toolchain to get what you want.

share|improve this answer
    
The idea is to have answers that stand for themselves and don't rely on links which can break in the future. Can you summarize the essentials of the referenced article into your answer? –  patrix Feb 15 '13 at 10:00
    
@patrix Thanks for the tip. I've made the correction. –  Global nomad Feb 15 '13 at 10:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.