Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

is there a way to copy list of all folders sub folders 10.8.2

Pretty much as the title says :


I was wondering if there was a way to copy a list of all the names of folders sub folders 10.8.2

into a text file / text files ?


I know I can select folders and files and command+c then paste them into a text file,

but this only works on the contents a single folder .

I want to be able to export as a text file the list of all folders and subfolders within, as I said.


It will be a very long text file, but I would "need" this feature.

Would help me enormously.


Thanks.

MacBook Pro (15-inch Late 2011), OS X Mountain Lion (10.8)

Posted on Dec 8, 2012 6:21 PM

Reply
Question marked as Best reply

Posted on Dec 8, 2012 6:36 PM

Are you game for learning a little Unix and knowing your Mac a little deeper? If you are, do know that OS X is Unix under the pretty graphics and regular Unix commands work just fine in Terminal.


So look up Terminal in Utilities and start it. A blank window will open and the command line prompt will await you at the bottom. First, try out the following Unix command to see if the results are what you want (type the following exactly, then press Enter/Return):


ls -R


If it is good, you will have to navigate to the topmost directory you want the list from. The -R (Recurse) option takes care of recursing down the tree. Use the cd command to change from the default (your home folder) to wherever you need to go. In Unix you separate directories with the / For example, the Utilities folder is in /Applications/Utilities and you can navigate to it by typing:


cd /Applications/Utilities


Can determine the names of all intervening folders by opening a Finder window to the desired place and Command-clicking on its name.


Holler if you need more help.

20 replies
Question marked as Best reply

Dec 8, 2012 6:36 PM in response to Benway1

Are you game for learning a little Unix and knowing your Mac a little deeper? If you are, do know that OS X is Unix under the pretty graphics and regular Unix commands work just fine in Terminal.


So look up Terminal in Utilities and start it. A blank window will open and the command line prompt will await you at the bottom. First, try out the following Unix command to see if the results are what you want (type the following exactly, then press Enter/Return):


ls -R


If it is good, you will have to navigate to the topmost directory you want the list from. The -R (Recurse) option takes care of recursing down the tree. Use the cd command to change from the default (your home folder) to wherever you need to go. In Unix you separate directories with the / For example, the Utilities folder is in /Applications/Utilities and you can navigate to it by typing:


cd /Applications/Utilities


Can determine the names of all intervening folders by opening a Finder window to the desired place and Command-clicking on its name.


Holler if you need more help.

Dec 8, 2012 7:02 PM in response to Courcoul

This sounds awesome Courcoul!
Thanks dude!


I'm definitely game to learn a bit! 🙂 😁


I was a kid in the last days of DOS, when it was a thing people used, on an old 486.

I can't remember it all exactly, but I remember how easy it was to navigate to old games that ran under DOS and other information.


Any commands like this I'm likely to use very often are worth knowing.


A third-party app to save my lazy brain the effort of typing commands is always good,

but I'm sure this will do just perfectly fine until / if I ever hear of one.


I'll try this a little later in the evening.

I'll let you know how I get along after I do it.


Cheers again!

Dec 8, 2012 7:14 PM in response to Benway1

The entire contents of the Terminal window is just text. Just as you'll be able to click-drag to select the ls output and copy it over to wherever you need it, so can you copy a folder PATH (starting from /) and paste it into the command line.


I usually keep a TextEdit window open alongside Terminal's as a cache holder for file paths and such.

Dec 8, 2012 8:15 PM in response to Benway1

AWEEESOME!

Thank you so much Corcoul, Niel, and Topher !


This is all enormously useful stuff ! I can't describe how useful it is for me.

And you may have helped me find a quick solution w/ text wrangler, [aka. life-saving app!], as well as getting me excited to learn how to do some specifics with finder.


I might youtube "Terminal 101" for some education, but I'd probably spend hours trying to get the same info as I am here.


Niel, your comment made me realize I could just select a folder in finder, then "copy+paste" it into terminal, and that shows the full path.

I'm too clumsy with drag+drop haha. Keyboard shortcuts ftw.


TEXT WRANGLER!!!!

yes yes yes yes yes !! LOVE. LOVE. LOVE.

Oh man, this appears to be almost a one-click solution!

I just tested it on a folder, and it gave me a total-full listing of all subfolders and files!

I'm jumping with crazy joy.


One question about it :

I'd love to know how to tweak listing everything,

for specific folders, to show just all subfolders,

and not their respective files and contents ;


[that list will be unnecessarily massive]


...for instance, if I was just looking to get a list of all my music/audio folders and their subfolders, there is no need for the individual files / tracks.

I don't need a list of all the individual tracks. Just the folders+their many subfolders / ie. albums.


[However, this is absolutely perfect for folders containing things like documents, or folders with lots of sub-folders filled with obscure applications,

where I do need a list of the individual files within all the subfolders.]


....but barring listing only folders and subfolders, this seems almost absolutely perfect !!!

and leaps+bounds ahead of where I was before.


I've been wanting to know how to do this easily for SO long! Wish I'd asked this a couple of years ago!


This helps me not fear the worst case scenario / major-phobia of all my backup disks dying, or being stolen, or my house burning down and years of all my obscure audio applications / documents / music being lost!

I can email this list to myself.


I'm insanely ecstatic about this!


Cheers-a-trillion!

Dec 8, 2012 8:45 PM in response to Benway1

If you use the "tree" command in that article, you can use the -d flag to have it list only directories. For instance, to list only directories on your desktop folder you would enter the following:


tree -d ~/Desktop/


This can also be output to a text file by redirecting the output like the following command:


tree -d ~/Desktop/ > ~folders.txt


This will create a file called "folders.txt" in your home directory that contains the output of the "tree" command so you can open it in other applications and print or otherwise manage it.

Dec 14, 2012 10:23 PM in response to Benway1

Hi Topher.
Thanks a lot!


Sorry I've been slack getting back to say thanks, it's been a busy week.


Is the command you mention for Terminal or Text Wrangler?


I'll try it out tonight on both if I can.


Also, kind of a small nothing-problem, but I no longer seem to be able to select a location in finder and copy past the full location/path in text wrangler; it just says, for example "desktop" or the name of the folder, without the full path.

No idea why that is. Tiny problem, but would love to know.

I'm a keyboard shortcut person, not a drag-and-dropper.


Cheers. (:

Dec 18, 2012 11:25 PM in response to Courcoul

Hey Courcoul. As per your awesome suggestions, I'm committing myself to slowly learning more about finder over coming weeks/months, and it's commands [or especially this one], rather than stoopidly relying on gui things. It'll be easy enough, I just have to learn a bunch of abbreviations and what they mean to navigate.

I tried your initial command [where I assume ls means "list structure" or something]

User's-MacBook-Pro:~ User$ /Users/[Username]/Music ls -R

What I get is this :


-bash: /Users/[username]/Music: is a directory


[Username's]-MacBook-Pro:~ User$

So essentially nothing.

Not sure what I'm doing wrong.

If you can suggest anything I'd love it.

I'll try and keep working on it, and look at your other posts.

Thanks dude.

Dec 19, 2012 12:14 AM in response to Courcoul

okay, I may be getting somewhere :
I first had to use the "cd" [change directory] command,

then dragged the music directory to terminal after this, and pressed enter.

As one would expect, this changed the directory in the terminal [feeling a bit sheepish for not understanding that first go]


and then I tried the "ls -R" again

[not sure what "R" [recursive] means yet]

but ;


This has given me a list of all folders and it appears subfolders.


Unfortunately, it has also given me a list of all files contained within each of these / under this tree, which I def. don't need for the music directory.


I think you gave me a command that will list only folders and subfolders, so I will try that next.


Sorry, I'm a bit slow and stupid, but I think it's coming along. (:

Dec 19, 2012 2:18 AM in response to Benway1

After changing the base directory in terminal from the home folder, to say, for example, the music folder by typing


cd /Users/[username]/Music


then pushing enter


I'd then LOVE to know the exact commands to just list folders and all their subfolders without showing files.


I think you told me above, and I looked through the article, but I still can't seem to get it.


Sorry to bother, I'll be doing a lot more of my own research, but I'd love to know how to do this fast for peace of mind.

is there a way to copy list of all folders sub folders 10.8.2

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.