Scripting.FileSystemObject
(1)
Vista
(1)
SNIPHow
(1)
XP
(1)
ActiveXObject
(1)
VBScript
(1)
JScript
(1)
Titles.txtOr
(1)

EXTREMELY TUSEFUL INFO - Printing Directory Listings

Asked By Stan Starinski
21-Nov-09 09:22 AM
This is a multi-part message in MIME format.

------=_NextPart_000_0021_01CA6A8C.162660A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Printing Directory Listings

Liz Browning would probably have written something like that in her blog =
if she lived today. Imagine her writing poetry on her laptop and saving =
it in a folder named C:\Sonnets, when suddenly she gets an email from =
her publisher saying he needs the titles of all the poems she is written =
so far. So Liz opens Windows Explorer and selects the C:\Sonnets folder =
to display a list of sonnets in the right-hand pane (Figure 1). Then she =
wonders, How can I print a list of titles of these files?


Figure 1. How can Liz print a list of titles of her sonnets for her =
publisher?

Funny how often users need to do this, yet there is no simple way to =
accomplish the simple task through the Windows GUI. Of course, if you =
are familiar with the command line or can do some scripting, it is not =
difficult. So, out of curiosity I decided to "count" the ways this =
simple task could be done in Windows; here is what I came up with.=20

1. Using the Command Line
The simplest way is to use the good old dir command with the /b switch =
to suppress everything except the filenames. For example, to display the =
names of files in C:\Sonnets, you do the following:

C:\>dir c:\sonnets /bwhich produces:=20
But only three in all God's universe.doc
Go from me. Yet I feel that I shall stand.doc
I lift my heavy heart up solemnly.doc
I thought once how Theocritus had sung.doc
The face of all the world is changed, I think.doc
Thou hast thy calling to some palace-floor.doc
Unlike are we, unlike, O princely Heart!.doc


You can either redirect the output to a text file with:

dir c:\sonnets /b > titles.txtOr you can redirect it to your default =
printer with:

dir c:\sonnets /b > prnIf you do not want to open a command-prompt window =
first, you can simply go to Start -> Run and type:

cmd /c dir c:\sonnets /b > lpt1If the directory you want to list =
contains subdirectories, you can use tree instead of dir:

cmd /c tree c:\sonnets /f > lpt12. Adding a Context Menu Item
It would be nice to right-click on a folder in Windows Explorer and =
print a list of items in the folder, would not it? This is easy to do by =
first creating the following batch script using Notepad:

@echo off
dir %1 /-p /o:gn > "%temp%\Listing"
start /w notepad /p "%temp%\Listing"
del "%temp%\Listing"
exitSave this with some name like printdir.bat in your %windir% =
directory, and add "Print Directory Listing" to your context menu for =
Windows Explorer as follows. Open the Folder Options tool in Control =
Panel, select the File Types tab, and in the File Types column select =
the item labeled File Folder. Then click on the Advanced button, click =
on New, and specify a name for the action you want to perform and the =
batch file that performs it (Figure 2):


Figure 2. Associating the batch file printdir.bat with the action "Print =
Directory Listing"

Once you are done, you can right-click on a folder in Windows Explorer =
and print a list of the files it contains (Figure 3):


Figure 3. Printing a directory listing from Windows Explorer

This hack is cool, but it has a flaw when you implement it on XP: after =
you have implemented it, every time you try to open a folder using Windows =
Explorer, the Search Companion window opens instead of the folder you =
selected. The workaround is a quick Registry edit described in Knowledge =
Base article 321379, where this hack is found. Of course, you can =
further customize the hack by tweaking the syntax of the dir command or =
replacing it with tree, and so on.=20

3. Using Windows Script Host
Windows Script Host lets you leverage the power of scripting languages =
like VBScript and JScript to automate almost any task you need to =
perform. For example, here is a simple JScript that will list the names =
of all the files in the C:\Sonnets folder:

var fso, e, file;
fso =3D new ActiveXObject("Scripting.FileSystemObject");
e =3D new Enumerator(fso.GetFolder("c:\sonnets").files);
for (e.moveFirst(); ! e.atEnd(); e.moveNext()) {
file =3D e.item();

Stan Starinski wrote this, with guidance from inner voices:SNIPHow 'bout just

Death replied to Stan Starinski
21-Nov-09 09:19 AM
Stan Starinski wrote this, with guidance from inner voices:

SNIP

How 'bout just posting the link, you putz.
Copy/Paste moron.

--
Vita brevis breviter in brevi finietur,
Mors venit velociter quae neminem veretur.

Wish you the same as your name.

Stan Starinski replied to Death
21-Nov-09 10:56 AM
Wish you the same as your name.

You missed it.

Retroman replied to Stan Starinski
21-Nov-09 11:24 AM
You missed it.  There is indeed a simple way in Vista, via Windows
Explorer:

1 ) Select the group of files in the right pane.
2 ) Press and hold the Shift key.
3 ) Right-click on the selection and choose "Copy as Path" from the
context menu.
4 ) Paste the list into Notepad and print.

Doug M. in NJ
Many thanks, it adds to my post.
Stan Starinski replied to Retroman
21-Nov-09 02:56 PM
Many thanks, it adds to my post.
In fact, yours is one of the most useful facts I [unexpectedly] learned in
months.

I often need Filetree listings due to complexity of my filesystem which
holds 16 years of professional work + home research/activites + several
other folks, and yet I managed to always use DOS-style commands for this
specific, rare operation.
I however think it happened because it was a pain in all Windows upward to
Vista.  What you just suggested maybe only appeared in Vista (I checked, it
works on my laptop), that is why I never knew... I was avoiding Vista until
it matured.
Stan Starinski wrote this, with guidance from inner voices:When will you
Death replied to Stan Starinski
21-Nov-09 04:24 PM
Stan Starinski wrote this, with guidance from inner voices:


When will you mature?
Everyone of your rambling post is some kind of half-ass bragging attempt.
By your spelling, my guess is you are a dumb-ass teacher at a public school,
and could not engineer your way out of a paper sack.

--
Vita brevis breviter in brevi finietur,
Mors venit velociter quae neminem veretur.
Try [url=http://www.print-directory.com]http://www.print-directory.
Pinos replied to Stan Starinski
23-Nov-09 05:56 AM
Try  [url=http://www.print-directory.com]http://www.print-directory.com[/url]


Post Originated from http://www.VistaForums.com Vista Support Forums
Post Question To EggHeadCafe