Save a Folder Listing to a Text File

Export what is inside a folder — names, sizes, dates — into a plain text file.

macOSFilesLow risk
Run ls -la folder > file.txt to write the detailed listing into a text file.

01Command

Command
$ ls -la ~/Desktop/Project > ~/Desktop/filelist.txt

02What it does

The > redirect sends the listing to a file instead of the screen; use >> to append a second folder instead of overwriting. For a recursive list including subfolders, use find . -type f > filelist.txt — handy for inventory or comparing what a backup captured.

03Risk

RiskLow risk
!Warning: > overwrites an existing filelist.txt without asking — use >> to add to it instead.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • cp – Copy files
    ss64.com · technical · 2026-09-17
    Evidence: The shell redirection operator > writes a command's output to a file; ls -la formats the listing with details.
  • find – Walk a file hierarchy
    ss64.com · technical · 2026-09-17
    Evidence: find . -type f can also list files recursively when you need every nested file, not just one level.

Last verified: 2026-09-18 · Category: Files & Folders

06Related solutions