Difference between revisions of "Copy the filenames of a directory to a text file"

From OpenTutorial
Jump to navigation Jump to search
(Type the Command)
 
Line 42: Line 42:
  
 
{{todo|todonote=someone else has to write this 'cause I know very little about Macs}}
 
{{todo|todonote=someone else has to write this 'cause I know very little about Macs}}
 +
 +
 +
== Linux (*nix) Operating Systems ==
 +
From a terminal
 +
 +
<code>ls -1 > dir.txt</code>
  
 
= Bibliography =  
 
= Bibliography =  

Latest revision as of 05:49, 9 February 2019

This tutorial explains How to Copy the Filenames of a Directory to a Text Tile This can be useful if you are trying to create a catalog of files that you have. If you want to share with others via email or html the contents of a particular directory. This tutorial explains how to do this under a variety of operating systems from Microsoft to Macintosh to Linux.

This tutorial will create a text file containing the filenames of all the files in a directory.


Microsoft Operating Systems

Get to a Command Prompt

For Windows 9x and ME above - goto start/run and type command into the box and hit enter

For windows 200, NT, XP - goto start/run and type cmd into the box and hit enter

Windows 3x - I don't remember but there should be an icon somewhere in Program Manager labeled "MSDOS Command Prompt" or something similar

DOS - That's just silly, you're already there.

Type the Command

Make the directory with the files you want the current directory.

Use the Following Command

dir /b > dir.txt

This will perform the dir command with the bare formatting switch. Creates a file named "dir.txt" and puts the output of the dir command into it.

Note: This example will also include the dir.txt file in the list. If this if not acceptable then change the path for dir.txt in the command

Example:

dir /b > c:\dir.txt


More info

For more information about the dir command type the following into your command window

dir /?


Macintosh Operating Systems


Linux (*nix) Operating Systems

From a terminal

ls -1 > dir.txt

Bibliography

  • (ISBN 0735619816) Microsoft Windows Scripting Self-Paced Learning Guide by Ed Wilson