Save a Folder Listing to a Text File
Export what is inside a folder — names, sizes, dates — into a plain text file.
Run ls -la folder > file.txt to write the detailed listing into a text file.
01Command
Command
$ ls -la ~/Desktop/Project > ~/Desktop/filelist.txt02What 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
!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 filesEvidence: The shell redirection operator > writes a command's output to a file; ls -la formats the listing with details.
- find – Walk a file hierarchyEvidence: 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
Find files larger than 500 MB on Mac
List the biggest files in your home folder that are eating disk space.
Show file extensions for all files on Mac
Make Finder display .pdf, .docx, .png and every other extension at all times.
Find Which Process Has a File or Volume Open with lsof
List every open file descriptor — files, directories, and network sockets — per process.