Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 09-12-2005, 12:41 AM   #1
gcoghill
Prospect
 
Join Date: Aug 2005
Location: Kent, OH
Posts: 46
Extract file names as text?

Anyone know of a way to get a text list of the contents of a folder?

For example, I have a folder of images, and want to extract the file names (to the clipboard or text clipping) to use in a text file. Any way to do this? Obviously I am looking for somethign that will batch grab them - I don't want to have to click on a file name, copy/paste for each one!

I thought there would be some free/shareware or AppleScript out there, but I haven't been able to find anything.
gcoghill is offline   Reply With Quote
Old 09-12-2005, 12:52 AM   #2
saint.duo
MVP
 
Join Date: Jan 2002
Location: Seattle
Posts: 1,084
TextWrangler has a folder listing insert option that will list the contents of a folder as text.
saint.duo is offline   Reply With Quote
Old 09-12-2005, 01:17 AM   #3
gcoghill
Prospect
 
Join Date: Aug 2005
Location: Kent, OH
Posts: 46
Wow, very cool! Thanks for the tip! I have heard a lot about TW, will have to dive into it now.
gcoghill is offline   Reply With Quote
Old 09-12-2005, 01:29 AM   #4
ever
Prospect
 
Join Date: Feb 2005
Posts: 10
open folder -> cmd-a -> cmd-c -> switch to textedit -> cmd-v
ever is offline   Reply With Quote
Old 09-12-2005, 08:07 AM   #5
guardian34
All Star
 
Join Date: Jul 2004
Posts: 713
You could also use AppleScript. This one asks you which folder to use:
Code:
choose folder with prompt "Get file listing of this folder:"

try
	do shell script "/bin/ls -1 " & quoted form of POSIX path of result
	set the clipboard to result
on error errorMsg number errorNum
	display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
end try
This one gets a list of the front Finder window:
Code:
try
	tell application "Finder"
		launch
		set the sourceFolder to (folder of the front Finder window) as alias
	end tell
on error
	set the sourceFolder to (path to desktop)
end try

try
	do shell script "/bin/ls -1 " & quoted form of POSIX path of sourceFolder
	set the clipboard to result
on error errorMsg number errorNum
	display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
end try
guardian34 is offline   Reply With Quote
Old 09-12-2005, 09:24 AM   #6
pink
Major Leaguer
 
Join Date: Jul 2002
Location: Germany
Posts: 441
Terminal:

Code:
ls /path/to/folder | pbcopy
paste as needed.

cheers, pink
__________________
"And what have we got in here ? - Ahh, things.." (Louis (2), inspecting kitchen cupboards.)
pink is offline   Reply With Quote
Old 09-12-2005, 10:11 AM   #7
guardian34
All Star
 
Join Date: Jul 2004
Posts: 713
Note that pbcopy doesn't support Unicode. (Thats why I don't use it the above AppleScript.)
guardian34 is offline   Reply With Quote
Old 09-12-2005, 12:28 PM   #8
Sumleilmus
MVP
 
Join Date: Sep 2002
Location: /
Posts: 1,121
Finder and TextEdit are enough.

Ever's method has worked well for me for at least a couple of years.
__________________
Sumleilmus
________
10.9.5 MacBook Pro 9,2 (13 inch, early 2013)
10.9.5 Mac Pro 3,1 (2 x 4core, 2008)
Sumleilmus is offline   Reply With Quote
Old 09-12-2005, 05:32 PM   #9
gcoghill
Prospect
 
Join Date: Aug 2005
Location: Kent, OH
Posts: 46
I guess I was looking too hardů

Quote:
Originally Posted by ever
open folder -> cmd-a -> cmd-c -> switch to textedit -> cmd-v

I can't believe I didn't try the most obvious solution. And I think of myself of somewhat of a power-userů

Thanks!
gcoghill is offline   Reply With Quote
Old 09-13-2005, 12:23 PM   #10
Sumleilmus
MVP
 
Join Date: Sep 2002
Location: /
Posts: 1,121
One more detail

Quote:
Originally Posted by ever
open folder -> cmd-a -> cmd-c -> switch to textedit -> cmd-v

In Tiger, in TextEdit, the Paste command to use is "Paste and Match Style" (cmd-opt-shift-c).
__________________
Sumleilmus
________
10.9.5 MacBook Pro 9,2 (13 inch, early 2013)
10.9.5 Mac Pro 3,1 (2 x 4core, 2008)
Sumleilmus is offline   Reply With Quote
Old 12-12-2012, 07:43 PM   #11
natx74
Registered User
 
Join Date: Dec 2012
Posts: 1
In addition to ever's post:
open folder -> cmd-a -> cmd-c -> switch to Text Wrangler -> cmd-v ... Then (this is cool)
go to the Text menu and drop down to Prefix/Suffix Lines and choose to either insert or remove either a prefix or suffix. Then type in whichever you want to remove or include (I choose to remove the .JPG from my file names) and whammo gone or added. I then cmd-a -> cmd-c -> into MS Word or Text Edit or any other WP software and Done. Hope this helps
natx74 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 01:53 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.