listing to a file

  • Thread starter Thread starter Guest
  • Start date Start date
Cecilia said:
how can a print the files names of a directory to a text file ?

Get a Directory Printer tool, or from the command line:

DIR > directory.txt

(you can use all the DIR command's switches for sorting and displaying
the results).
 
I found this article on how to automate a directory file listing using a
batch file but I cannot remember where I found it. It works really well for
me.
All of the text of the article is here but the pictures are not. I wish I
could remember where I found this so I could give credit where credit is
due.

<Begin article>"How many times have you been browsing through directories in
Windows Explorer and wished you could generate a text file or printout
listing the files and folders? It seems like such a simple request that it's
amazing the option isn't available. You don't believe me? Right-click on a
folder and see for yourself if there is an option to list or print the
structure. There isn't, but there is a workaround that doesn't require any
third-party software. Here's how to create a context menu item that, when
clicked, generates a printable (and editable) text-file listing of the
selected directory.

To create the entry in the context menu it's necessary to first create a
batch file. A batch file is a text file that contains a sequence of commands
for a computer operating system and uses the .bat extension. The format for
the .bat file is:

dir /a /-p /o:gen >filelisting.txt

The name of the .txt file can be whatever you like. In this example, I've
used filelisting.txt, but it could just as easily be filelist, listoffiles,
namedfiles, or even Wally if you enjoy the bizarre in your filenaming
schemes. Once you've decided on the filename, create the file in Notepad, as
shown in .


Figure 1. Creating a batch file in Notepad
Save the file in your WINDOWS folder as shown in , making sure to use the
..bat extension and not the default .txt extension. It's important to set
"Save as type" to All Files and "Encoding:" to ANSI.


Figure 2. Saving file listing.bat
Now that we have the .bat file created, the next step is to make it
functional and easily accessible by integrating it into the context menu
that opens when a right click is executed. Open Windows Explorer and choose
Tools ? Folder Options ? File Types tab ? Folder ? Advanced ? New, to open
the New Action box shown in .


Figure 3. Creating a new action for the context menus
In the Action box, type the name that you want to appear in the context
menu. Once again, you have wide latitude in choices; something like Create
File Listing will probably be most useful, but you can name yours something
more confusing if you like. Browse to the location of the .bat file you
created, and select it in the box labeled "Application used to perform
action." Click OK, and you'll see that Create File Listing (or whatever you
chose as an action name) has been added as one of the Actions in the Edit
File Type window, as shown in . Do the standard Windows dance of clicking OK
again to close all the open windows.


Figure 4. The revised Edit File Type box with your new action
That's it! Congratulations. You've created a new item on the context menu
that's ready to go to work. So, now that's it there, what can you do with
it?

Open up Windows Explorer. Navigate to whatever folder you want to use as the
basis for the file list, and right-click to open the context menu. Click on
the Create File Listing item (see ), and the list will be generated and
displayed at the bottom of the open Notepad window as filelisting.txt. shows
the file listing generated from the Sample Music folder shown in . Since it
is a text file, it can be fully edited, copied, pasted, printed, and so on
for any purpose.


Figure 5. Your new context-menu action: Create File Listing

Figure 6. The generated file listing, all ready for editing and printing
TIP
If for any reason you want to remove the Create File Listing entry from the
context menu, you must edit the Registry [Hack #68]. Navigate to
HKEY_CLASSES_ROOT\Folder\shell\Create_File_Listing and delete the
Create_File_Listing key in the left pane. Close regedit and reboot to
complete removal. <End article>




I hope this helps
 
Cecilia said:
how can a print the files names of a directory to a text file ?


From the command prompt (Start > Run > Cmd.exe), simply change to
the desired directory and type "dir > filelist.txt" or "dir > lpt1,"
just as you used to do in DOS. Any of the switches for the DIR command
(type "dir /?") will work with this command, if you wish to modify the
output. You can then subsequently edit the resulting text file using
NotePad, WordPad, Word, etc.

Alternatively:

HOW TO Add a Print Directory Feature for Folders in Windows XP
http://support.microsoft.com/?kbid=321379



--

Bruce Chambers

Help us help you:



They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety. -Benjamin Franklin

Is life so dear or peace so sweet as to be purchased at the price of
chains and slavery? .... I know not what course others may take, but as
for me, give me liberty, or give me death! -Patrick Henry
 
Try the freeware PrintFolder 1.2 . Go to bottom of page here
http://no-nonsense-software.com/freeware/. It puts an entry in your
right-click menu, so you just right click on the directory of choice ande
choose PrintFolder. There are some options for formatting the output. You
can print and/or save results to a file.
Anne
 
Cecilia said:
how can a print the files names of a directory to a text file ?


Here are four ways:

1. Go to a command prompt and issue the command

dir [drive:folder] > c:\tempfilename (you can use any name and put it in any
folder you want)

Then open notepad, open tempfilename, and print it from there.

2. Write (for example in Notepad) a 1-line text file:
DIR %1 /O >LPT1:

Save it as "printdir.bat" in the "Send To" folder.

Then, to print list of files in any folder, right-click that folder and
select Send to | printdir.bat

To include subfolders, change the comand to DIR %1 /O/S >LPT1:

3. Go to http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q321379 and
follow the instructions there.

4. Download and use any of the several freeware/shareware utilities that can
do this, such as the popular
http://www.karenware.com/powertools/ptdirprn.asp
 
I wonder if someone might know how to modify this so that the file it
generates, lands on your desktop every time?

M8RIX said:
I found this article on how to automate a directory file listing using a
batch file but I cannot remember where I found it. It works really well for
me.
All of the text of the article is here but the pictures are not. I wish I
could remember where I found this so I could give credit where credit is
due.

<Begin article>"How many times have you been browsing through directories in
Windows Explorer and wished you could generate a text file or printout
listing the files and folders? It seems like such a simple request that it's
amazing the option isn't available. You don't believe me? Right-click on a
folder and see for yourself if there is an option to list or print the
structure. There isn't, but there is a workaround that doesn't require any
third-party software. Here's how to create a context menu item that, when
clicked, generates a printable (and editable) text-file listing of the
selected directory.

To create the entry in the context menu it's necessary to first create a
batch file. A batch file is a text file that contains a sequence of commands
for a computer operating system and uses the .bat extension. The format for
the .bat file is:

dir /a /-p /o:gen >filelisting.txt

The name of the .txt file can be whatever you like. In this example, I've
used filelisting.txt, but it could just as easily be filelist, listoffiles,
namedfiles, or even Wally if you enjoy the bizarre in your filenaming
schemes. Once you've decided on the filename, create the file in Notepad, as
shown in .


Figure 1. Creating a batch file in Notepad
Save the file in your WINDOWS folder as shown in , making sure to use the
..bat extension and not the default .txt extension. It's important to set
"Save as type" to All Files and "Encoding:" to ANSI.


Figure 2. Saving file listing.bat
Now that we have the .bat file created, the next step is to make it
functional and easily accessible by integrating it into the context menu
that opens when a right click is executed. Open Windows Explorer and choose
Tools ? Folder Options ? File Types tab ? Folder ? Advanced ? New, to open
the New Action box shown in .


Figure 3. Creating a new action for the context menus
In the Action box, type the name that you want to appear in the context
menu. Once again, you have wide latitude in choices; something like Create
File Listing will probably be most useful, but you can name yours something
more confusing if you like. Browse to the location of the .bat file you
created, and select it in the box labeled "Application used to perform
action." Click OK, and you'll see that Create File Listing (or whatever you
chose as an action name) has been added as one of the Actions in the Edit
File Type window, as shown in . Do the standard Windows dance of clicking OK
again to close all the open windows.


Figure 4. The revised Edit File Type box with your new action
That's it! Congratulations. You've created a new item on the context menu
that's ready to go to work. So, now that's it there, what can you do with
it?

Open up Windows Explorer. Navigate to whatever folder you want to use as the
basis for the file list, and right-click to open the context menu. Click on
the Create File Listing item (see ), and the list will be generated and
displayed at the bottom of the open Notepad window as filelisting.txt. shows
the file listing generated from the Sample Music folder shown in . Since it
is a text file, it can be fully edited, copied, pasted, printed, and so on
for any purpose.


Figure 5. Your new context-menu action: Create File Listing

Figure 6. The generated file listing, all ready for editing and printing
TIP
If for any reason you want to remove the Create File Listing entry from the
context menu, you must edit the Registry [Hack #68]. Navigate to
HKEY_CLASSES_ROOT\Folder\shell\Create_File_Listing and delete the
Create_File_Listing key in the left pane. Close regedit and reboot to
complete removal. <End article>




I hope this helps
--
Mark N.
Cecilia said:
how can a print the files names of a directory to a text file ?
 
Works like a charm! A virtual beer to you, Louis! (helpful in my case
because it lets me print the file list of a server folder even if I have read
only access. Read only prevents the filelist file from getting written, but
redirecting to desktop works, and also lets you always find the file easily.)
 
Louis, Before you open that virtual beer i sent in my first reply, i found
that although the syntax you specify creates the text file on the desktop
correctly, the content of the text file is always the contents of my Windows
directory, no matter from which folder i invoke it. So there's still a
problem with the syntax...unless i'm reading it too literally, or
something....
 
Sorry, I didn't read the message that closely. Do the instructions given in
the article work without modification? I just copied and pasted what was
already there and inserted the path to your desktop.
Louis
(You were too late, the beer is gone!)
 
At first I thought the original worked OK as posted by M8RIX but it seems to
have some basic limitations...for example, the only way i can get the
contextual menu to appear, is to right click on a folder WITHIN the folder
i'm trying to list. If there's no subfolder in there, i can't launch the
batch file via right clicking. I guess one could temporarily create an empty
folder in there, to enable one to launch the batch file...but that's awkward.

Secondly, it only works for folders on my HD; it doesn't work for folders
located on a network server...at least not on OUR network server. I first
thought that directing the output to the desktop would resolve that, but it
appears that server permissions...or something...prevents it from working at
all for network folders.

C'est la vie :-)
 
Right click folder icon in titlebar.

cmd.exe /k dir \"%L\"> "%userprofile%\desktop\filelisting.txt"

A far better way, and a lot more modern than a 25 year old trick is

1/
You can drag a folder from (say explorer) on to the file. You can put it in
Sendto, type sendto in Start Run, copy the file into the sendto folder, then
right click the folder you want to list, Send To, PrintDetailsAppend.
Sending To simulates a drag and drop.

Then import the file into excel, delete the columns you don't want (as most
are blank for any individual type of file, eg MP3 don't have a Date Picture
Taken and JPEGs don't have a Genre property), sort it on description and
delete the files you don't want. That will leave just the properties and
files you want. This is the most general purpose way I can think of to meet
everyones needs.

A drive is the same as a folder for these purposes.

Attached is a VBScript that generate the shell properties (what you see or
could see in Explorer). It is a 51 column csv. There is about 40 properties
on a standard XP and I've allowed about 10 columns for custom properties
that applications may add. Those whove seen it before this one automatically
finds the desktop rather than editing the script. To use, drop a folder on
it or place in Sendto and send a folder to it. If using the for command
(below) you must run it once whereever you put it so it can be found.

To do sub folders type in a command prompt in the folder that you want to
start in (It also does the parent folder - a quirk of For)
for /r %A in (.) do start "" /w "PrintDetailsAppend" "%~dpA"

It creates a file on the desktop called Folder Property List.txt

Copy the following line into a text document and rename it to
PrintDetailsAppend.vbs

Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\App
Paths\" & Wscript.ScriptName & "\", Chr(34) & Wscript.ScriptFullName &
Chr(34)
WshShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\App
Paths\" & Left(Wscript.ScriptName, Len(Wscript.ScriptName)-3) & "exe" & "\",
Chr(34) & Wscript.ScriptFullName & Chr(34)

Set Fldr=objShell.NameSpace(Ag(0))

Set FldrItems=Fldr.Items
Set fso = CreateObject("Scripting.FileSystemObject")


Set DeskFldr=objShell.Namespace(16)
FName=fso.buildpath(DeskFldr.self.path, "Folder Property List.txt")


Set ts = fso.OpenTextFile(FName, 8, vbtrue)



For x = 0 to 50
t1 = t1 & Fldr.GetDetailsOf(vbnull, x) & " (Shell)" & vbtab
Next
ts.write FLDR.self.path &vbcrlf
ts.Write T1 & vbcrlf
T1=""


For Each FldrItem in FldrItems
For x = 0 to 50
t1 = t1 & Fldr.GetDetailsOf(FldrItem, x) & vbtab
Next
t1=t1 & vbcrlf
ts.Write T1
T1=""
Next
 
Windows Registry Editor Version 5.00
;----------------------------------
;To add a command to the context menu to print a directory listing to a file on the desktop.
;----------------------------------
[HKEY_CLASSES_ROOT\Directory\shell\List]
@="&List"
;----------------------------------
;Extended means you have to hold Shift while right clicking to see the verb
;----------------------------------
"Extended"=""
[HKEY_CLASSES_ROOT\Directory\shell\List\command]
@=hex(2):63,00,6d,00,64,00,2e,00,65,00,78,00,65,00,20,00,2f,00,63,00,20,00,64,\
00,69,00,72,00,20,00,22,00,25,00,4c,00,22,00,3e,00,20,00,22,00,25,00,75,00,\
73,00,65,00,72,00,70,00,72,00,6f,00,66,00,69,00,6c,00,65,00,25,00,5c,00,64,\
00,65,00,73,00,6b,00,74,00,6f,00,70,00,5c,00,44,00,69,00,72,00,6c,00,69,00,\
73,00,74,00,2e,00,74,00,78,00,74,00,22,00,00,00


Above resolves to
cmd.exe /c dir "%L"> "%userprofile%\desktop\Dirlist.txt"
--
--------------------------------------------------------------------------------------------------
How to lose a war in Iraq
http://webdiary.com.au/cms/?q=node/1335#comment-48641
=================================================
"David Candy" <.> wrote in message Right click folder icon in titlebar.

cmd.exe /k dir \"%L\"> "%userprofile%\desktop\filelisting.txt"

A far better way, and a lot more modern than a 25 year old trick is

1/
You can drag a folder from (say explorer) on to the file. You can put it in
Sendto, type sendto in Start Run, copy the file into the sendto folder, then
right click the folder you want to list, Send To, PrintDetailsAppend.
Sending To simulates a drag and drop.

Then import the file into excel, delete the columns you don't want (as most
are blank for any individual type of file, eg MP3 don't have a Date Picture
Taken and JPEGs don't have a Genre property), sort it on description and
delete the files you don't want. That will leave just the properties and
files you want. This is the most general purpose way I can think of to meet
everyones needs.

A drive is the same as a folder for these purposes.

Attached is a VBScript that generate the shell properties (what you see or
could see in Explorer). It is a 51 column csv. There is about 40 properties
on a standard XP and I've allowed about 10 columns for custom properties
that applications may add. Those whove seen it before this one automatically
finds the desktop rather than editing the script. To use, drop a folder on
it or place in Sendto and send a folder to it. If using the for command
(below) you must run it once whereever you put it so it can be found.

To do sub folders type in a command prompt in the folder that you want to
start in (It also does the parent folder - a quirk of For)
for /r %A in (.) do start "" /w "PrintDetailsAppend" "%~dpA"

It creates a file on the desktop called Folder Property List.txt

Copy the following line into a text document and rename it to
PrintDetailsAppend.vbs

Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\App
Paths\" & Wscript.ScriptName & "\", Chr(34) & Wscript.ScriptFullName &
Chr(34)
WshShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\App
Paths\" & Left(Wscript.ScriptName, Len(Wscript.ScriptName)-3) & "exe" & "\",
Chr(34) & Wscript.ScriptFullName & Chr(34)

Set Fldr=objShell.NameSpace(Ag(0))

Set FldrItems=Fldr.Items
Set fso = CreateObject("Scripting.FileSystemObject")


Set DeskFldr=objShell.Namespace(16)
FName=fso.buildpath(DeskFldr.self.path, "Folder Property List.txt")


Set ts = fso.OpenTextFile(FName, 8, vbtrue)



For x = 0 to 50
t1 = t1 & Fldr.GetDetailsOf(vbnull, x) & " (Shell)" & vbtab
Next
ts.write FLDR.self.path &vbcrlf
ts.Write T1 & vbcrlf
T1=""


For Each FldrItem in FldrItems
For x = 0 to 50
t1 = t1 & Fldr.GetDetailsOf(FldrItem, x) & vbtab
Next
t1=t1 & vbcrlf
ts.Write T1
T1=""
Next
 
Back
Top