5XÉçÇøÊÓƵ

print friendly version

Questions and answers

2554
How can I produce a list of files within a folder in Mac OS X?


One downside of the GUIs (Graphical User Interfaces) used on most computers is that it can be difficult to directly copy lists of files within folders. However it is relatively straightforward to generate a such a list.

Before use the facility has to be enabled.

Mac OS X 10.6

To enable this facility you need to download the OpenTerminalHere service from

After unzipping, copy the Open Terminal Here.workflow file into the Library/Services folder within your user home folder (if the Services folder does not exist at this location, you will have to create it).

Once copied, from the System Preferences… option choose:

  • Keyboard > Keyboard Shortcuts > Services
  • Tick the option Open Terminal Here

Once enabled, enabled [right-click] (or [ctrl-click]) in Finder on the folder for which you want to produce a file list and select Services… then Open Terminal Here from the menu that appears.

Mac OS X 10.7 and above

To enable this facility, from the System Preferences… option choose:

  • Keyboard > Keyboard Shortcuts > Services
  • Tick the option New Terminal at Folder

Once enabled [right-click] (or [ctrl-click]) in Finder on the folder for which you want to produce a file list and select New Terminal at Folder from the menu that appears.

The Terminal window

A blank window will appear with a cursor next to a $ prompt (text before the prompt may vary depending upon your username and/or setup). This is the Terminal window. Type the following text and hit enter:

ls > filelist.txt

Once the $ prompt reappears you can close the Terminal window. You will notice in Finder that the folder in question now includes an additional file called filelist or filelist.txt. Double clicking on this opens it in TextEdit to reveal that the file contains an editable list of files in that folder.

By default the list consists of just the file name, however the format of this list can be changed by altering the text typed at the $ prompt.

ls -l > filelist.txt

produces a list including permissions, owner, file size, last edited date and file name

ls -R > filelist.txt

produces list of all files within folder and any subfolders

Help us to improve this answer

Please suggest an improvement
(login needed, link opens in new window)

Your views are welcome and will help other readers of this page.

Categories

This is question number 2554, which appears in the following categories:

Created by Chris Limb on 25 February 2013 and last updated by Chris Limb on 17 June 2014