Knowing how to list all files in a folder is a fundamental skill for anyone working with computers, whether you are a casual user trying to organize photos, a data analyst processing CSV batches, or a developer automating deployment scripts. The method you choose depends heavily on your operating system, your comfort level with command-line interfaces, and the specific output format you require. This guide covers every major approach across Windows, macOS, and Linux, ranging from simple graphical clicks to powerful scripting techniques.
Using the Graphical User Interface (GUI)
For most users, the file manager is the first and most intuitive way to view directory contents. While it doesn't produce a text list you can easily paste into a spreadsheet, it provides immediate visual feedback Simple as that..
Windows File Explorer
Open File Explorer (press Win + E). work through to your target folder. By default, you see icons or a details list. To get a selectable list of filenames:
- Press
Ctrl + Ato select all files. - Hold
Shift, right-click the selection, and choose Copy as path. - Paste into Notepad or Excel. This gives you the full path for every item.
Pro Tip: Enable "File name extensions" and "Hidden items" on the View tab to ensure you are truly seeing everything Turns out it matters..
macOS Finder
In Finder, work through to the folder. Switch to List View (Cmd + 2) or Column View (Cmd + 3) for better readability. To copy a list:
- Select all items (
Cmd + A). - Right-click (or Control-click) and hold the Option key. The "Copy" menu item changes to Copy as Pathname.
- Paste into TextEdit or Notes.
Linux File Managers (Nautilus, Dolphin, Thunar)
Most Linux file managers behave similarly. In Nautilus (GNOME Files), press Ctrl + L to focus the location bar, copy the path, or select files and press Ctrl + C then paste into a text editor. Some managers (like Dolphin in KDE) offer a "Copy Location" or "Generate File List" plugin for more advanced formatting.
Command Line Methods: Windows
The command line offers speed, automation, and the ability to save output directly to a text file. This is essential for system administrators and power users It's one of those things that adds up..
The dir Command (Command Prompt / cmd.exe)
The classic dir command is built into cmd.exe.
- Basic list:
dir - Bare format (names only):
dir /b— Strips headers, dates, and sizes. Perfect for piping into other tools. - Recursive (include subfolders):
dir /b /s— Lists full paths for every file in the current directory and all subdirectories. - Save to file:
dir /b > filelist.txt— Redirects output tofilelist.txtin the current folder.
Example: To get a clean list of all .jpg files recursively and save it to your Desktop:
dir /b /s *.jpg > "%USERPROFILE%\Desktop\jpg_list.txt"
PowerShell (Get-ChildItem / ls / dir)
PowerShell is the modern, object-oriented shell for Windows. It treats files as objects with properties (Length, LastWriteTime, Extension), making filtering incredibly powerful.
- Basic list:
Get-ChildItem(aliases:ls,dir,gci) - Files only (exclude folders):
Get-ChildItem -File - Recursive:
Get-ChildItem -Recurse -File - Select specific properties:
Get-ChildItem -File | Select-Object Name, Length, LastWriteTime - Export to CSV (Excel ready):
Get-ChildItem -Recurse -File | Select-Object FullName, Name, Extension, Length, LastWriteTime | Export-Csv -Path "file_inventory.csv" -NoTypeInformation - Filter by extension:
Get-ChildItem -Filter "*.log" -Recurse -File
PowerShell is superior when you need to manipulate metadata immediately, such as finding files larger than 100MB modified in the last week:
Get-ChildItem -Recurse -File | Where-Object { $_.Length -gt 100MB -and $_.LastWriteTime -gt (Get-Date).
## Command Line Methods: macOS and Linux (Bash/Zsh)
On Unix-like systems, the `ls` command is the standard, but `find` and `tree` offer significantly more control for complex tasks.
### The `ls` Command
* **Standard list:** `ls`
* **Long format (permissions, owner, size, date):** `ls -l`
* **Show hidden files (starting with .):** `ls -a` or `ls -la`
* **Human-readable sizes (K, M, G):** `ls -lh`
* **One file per line (script friendly):** `ls -1`
* **Recursive:** `ls -R` (often messy output)
* **Sort by time (newest first):** `ls -lt`
* **Sort by size (largest first):** `ls -lS`
**Saving output:**
```bash
ls -1 > filelist.txt
ls -laR > full_recursive_list.txt
The find Command (The Powerhouse)
find is the gold standard for locating files based on criteria. It traverses the directory tree recursively by default.
- List all files only (no directories):
find . -type f - List files with specific extension:
find . -type f -name "*.py" - Case-insensitive name search:
find . -type f -iname "*.jpg" - Find files modified in last 7 days:
find . -type f -mtime -7 - Find files larger than 100MB:
find . -type f -size +100M - Execute a command on each file (e.g., print details):
find . -type f -exec ls -lh {} \; - Print full path with specific formatting (null-separated for safety with weird filenames):
find . -type f -print0 | xargs -0 ls -lh
The tree Command (Visual Hierarchy)
Not installed by default on all systems (sudo apt install tree or brew install tree), but invaluable for documentation.
- Basic tree:
tree - Files only:
tree -f(prints full path prefix) ortree -if(indented, full path). - Limit depth:
tree -L 2 - Show hidden:
tree -a - Output to HTML:
tree -H . -o folder_structure.html— Creates a browsable HTML map of your directory.
Using stat or ls with awk for Custom Formatting
If you need a specific delimiter (like CSV) without writing a script:
find . -type f -printf "%p|%s|%TY-%Tm-%Td %TH:%TM\n" > custom_list.txt
%p: Path%s: Size in bytes- `%TY-%Tm