Save Folder Contents as Text

Cory Blog, Other Tricks

Prepare yourself – here comes an ultra geeky tip.

Say you have this folder chucked full of files and for whatever reason you need a list of all the file and folder names inside that folder. No simple screenshot will work because you’re a nerd you want to see rows and columns and auto filter the names by characters and then cross reference them with another folder list. Ok, or you’re a normal human being and you just want to copy and paste the list of your music collection onto your Facebook profile. Either way, no will judge you if you bust out this little “DOS” command. Ya, I said “DOS.”

Stay with me. Open Windows Explorer and locate the folder that you want to save a list of files from. Hold down the SHIFT key, right click the folder, and select the Command Prompt item.

In the command prompt, type the following command.

dir > filename.txt

Press ENTER.

Make sure the command includes the spaces. This will create and place a text file in that folder called filename.txt with a list of all the files in the folder.

TIP: If you don’t have an “Open Command Window Here” option, you’re probably on Windows XP. You can download Microsoft’s “Open Command Window Here” powertoy from here.

For Mac users, the same can be done, although not as easily, using Automator. This tip comes from

[box] Automator makes it easy to get the contents of any folder on a Mac as a text file ready for printing, batch processing or any other purpose. First, open Automator and from the list of Finder Actions, double click on Get Selected Finder Items (or drag it from the Action list to the right side of the window). Then, double click on Get Folder Contents, and finally, double click on New Text File from the list of TextEdit Actions. For more flexibility, under the New Text File action’s options, check Show Action When Run and Show Selected Items with both Save As and Where options checked. The Finder will in return, ask you where to save the file and how to name it. Save the action as a Finder plug-in, and control-click on any folder in the Finder to run your newly-created action from the contextual menu. The contents of specified folder will be saved in a text file (one item per line), incredibly useful in certain situations. (Now, if scripting is your niche, I also find it useful to trim the path of the file and keep the names only…)[/box]

What I love about this is that it’s built in – you don’t have to download any software to make this happen. So now you’re set the next time to need a list of those files.