I want to create lists of files from folders but don’t know how to do it. I can use a Command prompt and run a command to list all the files in a folder and redirect the output to a text file on my old Windows PC. For example, the command - dir /b > filelist.txt would list all the files in the directory with just the file names (/b gives ‘bare’ file names only, and >file list.txt puts the list into a text file called file list.txt). When I run this command in Mac Terminal, it won’t work. Is there a command line in Terminal that would replicate this?
The equivalent to dir in Windows CMD is ls in Mac Terminal. To get the list of file names in a folder on Mac, you can:
- Open Terminal.
- Enter ls to list default folders in your user directory.
- Continue entering ls foldername filelist.txt. You need to replace foldername with your target folder name.
1 Like
Hey, bro. There’s no need to use command lines to copy the list of file names in a folder on your Mac. Just open the target folder, then press Command-A to select all the files. Press Command - C to copy all the selected files, open a text-only app like TextEdit, and then press Command - V to paste the file names to the text. You can get a list of file names for sharing or other use.
Thanks a lot. I’m new to MacBook.
Simple way! The complex command lines are replaced with shortcuts.