Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Copy and paste directory listings Desktop
If you need to copy a list of files you have in a folder to email somebody, or just for yourself, then do the following:
  1. Open the desired folde in the finder
  2. Select the items you need to list
  3. Go to Edit / Copy
  4. Then go to your e-mail or text-edit program and select Edit -> Paste
[Editor's note: When using this copy and paste method, make sure you've clicked into the destination app before pasting, otherwise you'll invoke the Finder's "other" definition of paste, and make a copy of everything you've selected!]
  • Currently 4.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)

Copy and paste directory listings | 13 comments | Create New Account
Click here to return to the 'Copy and paste directory listings' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Always Reverse Alphabetical?
Authored by: cbseven on Jul 20, '02 11:46:48AM

A great hint...and so obvious!

I'm surprised that I never tried this. I'm always needing to operate on a list of files one at a time, and have always created a checklist by writing down the filenames on [gasp] paper.

It seems however, that the pasted list is always (?) in reverse alphabetical order, regardless of the finder window sort order. Am I missing something?

[ Reply to This | # ]
Always Reverse Alphabetical?
Authored by: mervTormel on Jul 20, '02 11:54:28AM

list properly sorted here.

[ Reply to This | # ]
You can do it with the shell, too.
Authored by: jules on Jul 21, '02 11:31:43AM
Bring up the Terminal and find the directory you're interested in. Type: ls -c | sort | pbcopy Now the filenames are on the clipboard. The ls command is potentially more interesting as you can pull out just, say, doc files (if you label your goodies with suffixes of types): ls -c *.doc | sort | pbcopy

[ Reply to This | # ]
Authored by: rgray on Jul 20, '02 12:44:11PM

OK maybe this a naive question, but why can't you use the 'Services > Mail > Mail to' menu item to accomplish this?

[ Reply to This | # ]
Authored by: Eravau on Jul 21, '02 06:07:49PM
I don't know about your Finder, but in my Finder, when I select files, there are no options available from the Services menu. Everything is grayed out. Come to think of it, I've come across almost zero apps that use the Services.

[ Reply to This | # ]
Services are kind of Cocoa only.
Authored by: etwoy on Jul 21, '02 10:22:21PM

Services were initally only available to Cocoa applications, not Carbon ones. The is a Carbon app.

This has changed recently though, and Carbon developers now have access to Services. As of 10.2, the Finder can take advantage of them.

Services rock! My favourit is CalcService, which lets you type in a calculation in any Cocoa text app, and then use Services to calculate it. Awesome.

[ Reply to This | # ]
what about comments
Authored by: elmimmo on Jul 20, '02 01:05:04PM

I make extensive use of comments in files, those that you can enter by clicking apple + i. Is there any way to make a list of files in a certain folder/s AND their comments?

[ Reply to This | # ]
alphabetical listing
Authored by: zossimos on Jul 20, '02 05:01:48PM

I'm certain there is a way in the Terminal to copy and paste an alphabetical listing, I think to write the list to a .txt file? Anyone know?

[ Reply to This | # ]
alphabetical listing
Authored by: Anonymous on Jul 20, '02 06:17:56PM
Writing to a file: ls -ls > filelist.txt for long file info ls -1 > filelist.txt (that's -one) for just file names. Writing to clipboard: ls -ls | pbcopy for long file info ls -1 | pbcopy (that's -one) for just file names. Obviously, you can use any arguments to ls to get your preferred formatting.

[ Reply to This | # ]
alphabetical listing
Authored by: tripfactor on Jul 20, '02 08:19:58PM

ShellService is a service component — it provides functionality that other applications use.In the Services menu (under the application menu), ShellService adds an item called Execute Text. This item will be enabled whenever you have text selected in applications which support the service.

In other words, to get a dir listing into the mail app, just type "ls" highlight it and then select execute text in the service menu. No copy or paste needed. And because it works with any unix command output you can make the listing any format you buy using the command's options.

[ Reply to This | # ]
alphabetical listing
Authored by: BraindeadMac on Jul 22, '02 08:08:58AM
the undocumented pbcopy and pbpaste commands allow you to copy and paste to the clipboard. For instance to get a home directory listing:
ls ~ | pbcopy
This will place the listing of the directory into the clipboard and you can then paste into whatever application you want.

[ Reply to This | # ]
alphabetical listing
Authored by: snit on Jul 22, '02 09:41:12PM

I added the following to my .login (actually a file called .aliai which is sourced from my .login)

alias "DT" "cat >> ~/Desktop/DT.txt"

I can now have any command's output redirected to a file on my desktop called DT.TXT, appending any new text to the end of the file

If I do not want it to append to an old DT.txt that may already exist, I use the DTo command defined by the following alias

alias "DTo" "cat > ~/Desktop/DT.txt"

Either can be used as follows:

ls -la | DT

the secret is the "piping" through the DT ( or DTo) command.

I suppose I could enter this as a hint all by itself. :)

[ Reply to This | # ]
Welcome to System 6
Authored by: ~Coxy on Jul 21, '02 10:36:34AM

At least... this feature may be even earlier than that. :D

[ Reply to This | # ]