New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Apps and Games Discussion of applications and games available for Mac OS X.

How to get contents of folder into a .txt file?


Post Reply New Thread Subscribe

 
Thread Tools
rsherid

 
Member Since: Sep 06, 2008
Posts: 782
rsherid is infamous around these parts
Mac Specs: 13" MBP - 2.7 Ghz, Intel Core i7, 8GB RAM.

rsherid is offline
I need the contents of a folder to be displayed in a .txt file, but unlike with Automator, I don't need the entire directory to be listed -- just the files as they appear in the folder.
QUOTE Thanks
XJ-linux

 
XJ-linux's Avatar
 
Member Since: Jul 02, 2007
Location: Going Galt...
Posts: 3,312
XJ-linux has a reputation beyond reputeXJ-linux has a reputation beyond reputeXJ-linux has a reputation beyond reputeXJ-linux has a reputation beyond reputeXJ-linux has a reputation beyond reputeXJ-linux has a reputation beyond reputeXJ-linux has a reputation beyond reputeXJ-linux has a reputation beyond reputeXJ-linux has a reputation beyond reputeXJ-linux has a reputation beyond reputeXJ-linux has a reputation beyond repute
Mac Specs: MacBookAir5,2:10.9.2-MacMini3,1:10.9.2-iPhone6,1:7.1

XJ-linux is offline
open terminal, cd to the folder, type ls, then copy and paste into your text editor.

Privacy has become a luxury good. Be prepared to budget for it from here on out...
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,620
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
Easier....


ls > whatever_you_want_to_name_it.txt


ls -l if you want more information... ls -lh if you want filesizes to be human readable


ooooo if you really just want the FILES, not subdirectories..


find . -depth 1 -type file > filename.txt

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
rsherid

 
Member Since: Sep 06, 2008
Posts: 782
rsherid is infamous around these parts
Mac Specs: 13" MBP - 2.7 Ghz, Intel Core i7, 8GB RAM.

rsherid is offline
find . -depth 1 -type file > filename.txt

Where do I type that in? Do I start with the period?
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Ottawa
Posts: 17,103
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
That is a command that you input into the Terminal (/Applications/Utilities/Terminal.app).

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Mac-Forums Investigates MacKeeper - Confused about MacKeeper? Take a look at this review.
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,620
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
In addition to vansmith's excellent point (I completely forgot to mention how to get there) the find statement is the start of the command. So it will look like this..

mikeMbp:~ mike$ find . -depth 1 -type file > examlpleFile.txt
mikeMbp:~ mike$

Now the contents will look something like this..

./.ano
./.bash_history
./.CFUserTextEncoding
./.DS_Store
./.lesshst
./.profile
./.syncdocs
./.viminfo
./.Xauthority
./able.preferences
./ANALYS32.XLL
./dscli
./examlpleFile.txt

if the ./ is a problem we can ditch that by doing something like this...

find . -depth 1 -type file | sed 's:./: :' > examlpleFile.txt

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
technologist

 
Member Since: Mar 30, 2004
Location: USA
Posts: 4,744
technologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond repute
Mac Specs: 12" Apple PowerBook G4 (1.5GHz)

technologist is offline
Geez. Why does everybody jump for the Terminal for such a simple problem?

Open a folder.
Choose Edit > Select All
Choose Edit > Copy
Open a text editor, such as BBEdit or TextWrangler.
(Important note: if you use TextEdit, make sure you are using Plain Text mode. By default, you can do this by choosing Format > Make Plain Text. You should not see the toolbar with Style and Line Spacing.)
Choose Edit > Paste
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Ottawa
Posts: 17,103
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
The only thing I have noticed with Dysfunction's idea, which I would have also suggested, is that the file you redirect output to (I think that's the right phrase) will also include the name of the file you redirect to. To clarify, let me show you.

If I execute ls > test.txt in my home directory, the content of test.txt is as follows:
Desktop
Documents
Downloads
Library
Movies
Music
Pictures
Public
Sites
test.txt

So, as you can see, the file you are trying to save the output of ls to is also included in that list. This also occurs for the aforementioned find command. One simple way around this would be to redirect to a file outside of the directory you are trying to get the contents of. So, for instance, you could execute the following:
Code:
ls > ~/Desktop/test.txt
If you prefer Dysfunction's find command above, you can also change the redirect file:
Code:
find . -depth 1 -type file > ~/Desktop/exampleFile.txt
Each of these will output the file to the desktop. You can of course change where the file is written to.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Mac-Forums Investigates MacKeeper - Confused about MacKeeper? Take a look at this review.
QUOTE Thanks

Post Reply New Thread Subscribe


« Can someone help me with setting up my email? | Apps keep quiting »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Moving mp3's to your Audiobooks folder bobtomay iPod Hardware and Accessories 10 10-10-2009 12:02 PM
Internet help ( quick) watzup Switcher Hangout 8 09-22-2006 09:07 AM
File Icons & Associations confusion markwm OS X - Operating System 1 03-04-2006 10:38 PM
Changing folder / file names... why so hard? iFX Switcher Hangout 9 05-17-2005 10:15 PM
Can you guys open this site? Desolate One OS X - Apps and Games 13 04-29-2005 01:23 PM

All times are GMT -4. The time now is 11:20 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?