Skip to Main Content



File Management

Tips for managing digital files by the Iowa State University Library

File lists

Uses

When organizing and maintaining existing files, it often is useful to generate a list of all files in your shared directories. Possible uses include:

  • Reviewing file and folder names to determine whether file-naming conventions are being followed.
  • Determining which files may be archived or deleted.
  • Creating an inventory for reporting purposes.

Shell commands

You can use shell commands to generate file lists that include such information as name, location, size, and date last modified.

Note: Before using shell commands, you should be familiar with viewing files in File Explorer (Windows) or Finder (Mac). If you are using a cloud-based storage application, such as Box, Google Drive, or Dropbox, you may need to install a free desktop application to access your files through File Explorer or Finder. Go to the application's website for details.

Command quick reference

 

List file and folder details, including subfolder contents

List top-level file and folder details

List file and folder names, including subfolder contents

List top-level file and folder names

Terminal

ls -Rl ls -l ls -R ls

Power
Shell

Get-ChildItem -Recurse Get-ChildItem Get-ChildItem -Recurse -Name Get-ChildItem -Name

Command Prompt

dir /S dir dir /B /S dir /B
Instructions

Use these links to view instructions for the following applications:


Mac

Starting in Finder
  1. In Finder, navigate to the top-level directory (folder) you want to view.
  2. Select the folder.
  3. Right-click the folder; then choose New Terminal at Folder.
  4. In Terminal, on the command line, type or paste one of these commands:
  • Output results in the shell window: ls -Rl
  • Output results in a TXT file (saved in the top-level directory): ls -Rl > filenames.txt

Note: -Rl includes details about all subfolders and their contents in the list. ("R" means recursive.) If you want details about only the top-level folder contents in your list, use ls -l . If you want file and folder names without file properties, use ls -R or ls.

Starting in Terminal
  1. Open the Terminal application.
  2. On the command line, type cd and the path name—for example, cd /Users/abc/Documents
  3. Type your desired command.

Note: To get the path name, go to Finder and select the folder you want to view. Then choose one of these options:

  • Right-click the path at the bottom of the window; then choose Copy [file/folder name] as Pathname. Then paste the path on the command line.
  • Drag the folder from Finder to the Terminal window. The path is copied to the command line.

For more information, see the Apple documentation.


Windows PowerShell

Starting in File Explorer
  1. In File Explorer, navigate to the top-level directory (folder) you want to view.
  2. Select the folder.
  3. Choose one of these options:
  • Press Shift and right-click; then choose Open PowerShell window here.
  • Go to the File menu; then choose Open Windows PowerShell.
  • In the location bar, select the file path; type powershell; and press Enter.
  1. In PowerShell, on the command line, type or paste one of these commands:
  • Output results in the shell window: Get-ChildItem -Recurse
  • Output results in a TXT file (saved in the top-level directory): Get-ChildItem -Recurse >> filenames.txt

Note: -Recurse includes details about all subfolders and their contents in the list. If you want details about just the top-level folder contents in your list, use Get-ChildItem only. If you want file and folder names without file properties, add -Name after your command.

For more information, see the Microsoft documentation.


Windows Command Prompt

Starting in File Explorer
  1. In File Explorer, navigate to the top-level directory (folder) you want to view.
  2. Select the folder.
  3. In the location bar, select the file path; type cmd; and press Enter.
  4. In Command Prompt, on the command line, type or paste one of these commands:
  • Output results in the shell window: dir /S
  • Output results in a TXT file (saved in the top-level directory): dir /S > filenames.txt

​​​​​​Note: /S includes all subfolders and their contents in the list. If you want only the top-level folder contents in your list, use dir only.

Starting in PowerShell or Command Prompt
  1. Open the PowerShell or Command Prompt application.
  2. On the command line, type cd and the path name—for example, cd "C:\Users\abc\Documents"
  3. Type your desired command.

Note: To get the path name, go to File Explorer and select the folder you want to view. Then choose one of these options:

  • Go to Home and select Copy path. Then paste the path on the command line.
  • Drag the folder from File Explorer to the shell window. The path is copied to the command line.

 

Contact information

Questions? Contact us!

Consultations are also available by request.

Megan O'Donnell, Research Data Services Lead

datashare@iastate.edu

Heather Campbell, Head of Metadata Services

metadata@iastate.edu

File Management by Heather Campbell and Megan O'Donnell is licensed under CC BY 4.0 Attribution