Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I use Finder to locate a set of files, I want to save the list of files to a text file (preferably with path names).

I know I can open the shell and use 'find', but what's the point of having a GUI if you have to remember the syntax for shell commands still to get the job done? :)

Is there a way to save the result list to a file?

share|improve this question

4 Answers 4

up vote 1 down vote accepted

Create a simple AppleScript:

on open (fileList)    
    set outFile to (choose file name with prompt "Output file:" default name "FileList.txt")    
    open for access outFile with write permission    
    repeat with oneFile in fileList    
        write (POSIX path of oneFile) & "    
" to outFile    
    end repeat    
    close access outFile    
end open

... and save it as an application. To use it, select all in the search window, then drop the list of files on the AppleScript. It can also be used with any other sort of list-of-files-from-the-Finder.

EDIT: If you want to set this up as a service rather than a droplet (and are running Snow Leopard), create this in Automator rather than AppleScript, use the "Service" template, set the "service receives select" pop-up to "files and folders", add a Run AppleScript action, paste in the above script, but with on run {fileList, parameters} ... end run instead of on open (fileList) ... end open. Save it with some appropriate name, and then to use it, select the files, right-click (or control-click), and select Services > yourservicename from the pop-up.

share|improve this answer
    
Excellent! I will definitely try that. –  Stabledog Mar 11 '10 at 18:46

the find command is a standard unix command, it is not an interface to spotlight.

The command line interface to spotlight is the mdfind command. For example to find files called foo.txt one would type mdfind -name foo.txt

Like any other Unix command, its output can be redirected into another file, using the > operator. for example, mdfind -name foo.txt > bar.txt would do the above search for files called foo.txt, and put the results into a file called bar.txt in the current directory.

For more info on the command line interface to spotlight, check out the mdfind manpage

share|improve this answer
    
Yes, I'm well aware of the 'find' command, that's why I mentioned it in the question. I'm trying to do this in the GUI. –  Stabledog Mar 11 '10 at 12:24
    
my point was, the find command does not actually use spotlight so if you or anyone else did end up giving up and piping the results from the command line, you would be bypassing the spotlight index and causing a HUGE performance hit. any gui that achieved this would simply be a text field to enter your search term, and not much else. this is basically a command line anyway surely? –  JonnieCache Mar 11 '10 at 12:30
    
Not sure what you're saying: Finder is using an index. It's showing me a list of the files found. It's quick and efficient. It knows the names of all the items found. I want a way to retrieve those names into the clipboard, that's all. This really doesn't have any significant performance hit. –  Stabledog Mar 11 '10 at 12:33
    
However, I didn't know about 'mdfind', so that part is indeed useful. Even worse, I stopped reading when it sounded like you were recommending 'find', so now I've earned the "sloppy reader" badge :) –  Stabledog Mar 11 '10 at 12:35
    
find does not use any index. it simply walks the directory tree. this is very slow, but on some unix systems where there is no indexing system set up, there is no alternative. mdfind behaves in the same way (roughly) but it uses spotlight's advanced indexing system and is therefore orders of magnitude faster than the normal find command. I simply wanted, in the eventuality that you or someone else does end up using the command line to solve this problem, to make sure they used the spotlight index rather than the blunt directory walk that find does. –  JonnieCache Mar 11 '10 at 12:40

You can right-click on the results and select "Copy N items". That will copy the file names without their path to the clipboa–er, pasteboard.

Not ideal, but it might be start?

share|improve this answer
    
Well yes, it is a start. I didn't even think that far :) –  Stabledog Mar 11 '10 at 12:25

There also exist many third party GUI interfaces to spotlight, such as filespot. I am sure one of these must have comprehensive export options.

share|improve this answer
    
Filespot looks interesting. Unfortunately, the download links are 404... and Google doesn't seem to offer alternative sources. Any idea what's going on with that? I sent them email, perhaps they'll fix the link. –  Stabledog Mar 11 '10 at 13:07

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.