Print Tree/File List

Support for xplorer² free lite version

Moderators: fgagnon, nikos, Site Mods

hpp3
Member
Member
Posts: 51
Joined: 2004 Jun 04, 15:36

Print Tree/File List

Post by hpp3 »

Thanks Nikos for the greatest file manager I have ever used. One thing I hope to be able to do is print a list of files in a directory or a tree structure. I won't annoy you with "well program X lets me do it, how come x2 doesn't?" so all I'm asking is there a way x2 can, and if not might it in the future?
Thanks again.
User avatar
fgagnon
Site Admin
Site Admin
Posts: 3737
Joined: 2003 Sep 08, 19:56
Location: Springfield

Post by fgagnon »

Sort-of (in a two step process).
You can copy the items to a file, & then print the file.

select the items you want to list, then use:
Edit | Copy names {or Alt+C}
to put names on clipboard,
from there you can paste into a file of your choice for printing.

to copy all columns of the selected items to clipboard in a tab-separated list, use:
Edit | Copy columns {or Ctrl+P}
hpp3
Member
Member
Posts: 51
Joined: 2004 Jun 04, 15:36

Post by hpp3 »

Good enough. Any way to select only the name column, or other combination thereof?
Thanks!
User avatar
fgagnon
Site Admin
Site Admin
Posts: 3737
Joined: 2003 Sep 08, 19:56
Location: Springfield

Post by fgagnon »

Copy names copies just the name column,
Copy columns copies all columns showing in the view.
(In other than detail view only the names are copied)

In detail view, you can customize which columns are displayed using the column selector tool button, or use keycombo Alt+K, or r-click on any column heading to bring up the column selector dialog.
User avatar
JRz
Gold Member
Gold Member
Posts: 560
Joined: 2003 Jun 10, 23:19
Location: NL

Post by JRz »

As an alternative, you can also use a command line to get what you want.

Try putting this in the address bar (you can also make it a user command, for easy access when you need this in the future):

Code: Select all

$ dir /b
This will give you a list in the command window of all folders and files in the current active pane (normal command prompt if you've disabled using the extended command window Nikos provides).

To get only files you'd use this:

Code: Select all

$ dir /b /a-d
You can also specify a different sort order if you like:

Code: Select all

$ dir /b /a-d /o-s
This will sort on size (largest first)

To directly put this on the printer you simly redirect the output of the command to PRN, like this:

Code: Select all

$ dir /b /a-d /o-s > prn
This will print a list of all files in the current active pane, sorted by size descending directly!

There is virtually no limit to what you can do using the command line when it comes to file handling. If you don't want to see extensions of files, for instance the command becomes a bit more difficult, but you only have to worry about that once, because you can save the command for later reusage (as a user command)!

Code: Select all

$ for /f "usebackq tokens=*" %i in (`dir /b /a-d /o-s`) do @echo %~ni > prn
Note that this last command will only work for Windows versions Windows 2000 and up!
It will print the same list as before, but now only filenames without extensions!! The 'for' command is a treasure; Bill G. III finally decided from windows 2000 onwards to make command substitution available for this command, so you can use the output of a command and process this further (notice that I used backquotes around the dir command above!!)
This is common in Unix since as long as I know, to be able to use a command between backquotes like this.
You can get information about the syntax and usage of these commands by simply typing '/?' behind it in a command prompt. So for instance:

Code: Select all

C:\> for /?
will tell you what is possible using the 'for' command.

Hope you can do something with this...
Dumb questions are the ones that are never asked :turn:
User avatar
nikos
Site Admin
Site Admin
Posts: 16296
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

you gave me a headache! :)
never done anything as fancy with for
User avatar
JRz
Gold Member
Gold Member
Posts: 560
Joined: 2003 Jun 10, 23:19
Location: NL

Post by JRz »

nikos wrote:you gave me a headache! :)
never done anything as fancy with for
Sorry for the headache Nikos,

But then your head is going to spin after you have read all help screens that result from doing 'for /?' :spin:

It is a really powerful command!! (not nearly good enough to match what you can do on a Unix system though; that's why I use the ported versions of the Unix commands like grep, sed, wc, etc. from http://cygwin.com/ too :) )
Dumb questions are the ones that are never asked :turn:
User avatar
fgagnon
Site Admin
Site Admin
Posts: 3737
Joined: 2003 Sep 08, 19:56
Location: Springfield

Post by fgagnon »

Jan,
My first impulse was, indeed, to suggest $ dir > prn (& a couple of the options you mentioned) until I tested it on XP with printer connected to virtual printer port on USB001.
It doesn't work for that case.
Hence the two-step recommendation to get printout.

Of course the unredirected command

Code: Select all

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
  [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]
does work to get console display. :)
User avatar
JRz
Gold Member
Gold Member
Posts: 560
Joined: 2003 Jun 10, 23:19
Location: NL

Post by JRz »

Fred, this is probably due to the fact that DOS doesn't recognize any USB devices in your case.

You'd have to have support for USB for DOS. Secondly, when installing printer drivers, there's often an option to specify if you would want to be able to print from DOS programs. You will need that too, to redirect to PRN from the command prompt :)

The obvious thing to do for such a 'complex' task, is to make a script for it (so you can reuse it over and over again, even without the user command feature of :) )

Below is a sample of how you could print a file list from current folder, without extensions and sorted by size descending (like the example in my previous post). What the script does is:

1. put all info to be printed in a temporary file
2. open the file in an editor (Editor² of course ;) )
3. let user print it from there
4. remove temporary file when done

This way the output is not redirected to the printer right away (to circumvent the problem you described Fred), but saved in a file. You can decide what to do with it from there (even edit the list of course). You could of course make this script available as a user command for easy access from .

Simply put the code below in a file named 'PrintFileBySize.cmd' and make a user command excuting this script. I've put in some comments to explain what the various commands do.
Note that the same restriction of having at least Windows 2000 applies here too. Notice the difference in the syntax of the 'for' command with the one in my previous post: the parameter %i now needs two %% in front of it, because it is used from a command script, which itself uses the '%'-sign to identify variables (see %fileName% for instance). So you have to 'escape' the '%'-sign in the 'for' command to make it work (yes Nikos, there are many quirks in using command script language, but it gets the job done ;) )
Needless to say you can vary the 'dir' command in the script to produce any sort of file list you want for your purposes. You could even make the script parameterized, to let the user choose what he wants when executing!!
As I've said before, virtually no limit to what you can do...

Code: Select all

@echo off
rem use a variable to specify the temporary file to use
rem %temp% will make sure it goes into the TEMP folder
rem %~n0_TMP.txt will give it the name of this script followed by '_TMP.txt'
rem Example: script name = 'PrintFileBySize.cmd'
rem          fileName    = 'PrintFileBySize_TMP.txt' 

set fileName= %temp%\%~n0_TMP.txt

rem make sure the file does not exist already (just in case a previous attempt left it in %temp%)
rem redirect output of the 'del' command (if any) to nul device and make sure that goes for errors too
rem by redirecting stderr (2) to stdout (1) ('2>&1' takes care of that)
del %fileName% /f/q > nul 2>&1

rem Fill the file with the files without extensions in current folder sorted by size desc
rem using double redirection marks to append to the file
rem because the 'for' command produces the items one by one
for /f "usebackq tokens=*" %%i in (`dir /b /a-d /o-s`) do @echo %%~ni >> %fileName%

rem Start Editor² (Unicode version) and load the file so you can print it
start /wait /D"C:\Program Files\zabkat\xplorer2" Editor2_UC /V %fileName%

rem When finished with Editor², delete the temporary file
del %fileName% /f/q > nul 2>&1

rem Done :)
Cool isn't it 8)

[I've put this line below in to make the screen wide enough to get every line of the script on one line; don't know any other way to get this done; sorry :?]
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Dumb questions are the ones that are never asked :turn:
User avatar
nikos
Site Admin
Site Admin
Posts: 16296
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

this is a masterclass in over-engineering!
what about making a "batch" file (ctrl+A, ctrl+B) with $B end editing it?
User avatar
JRz
Gold Member
Gold Member
Posts: 560
Joined: 2003 Jun 10, 23:19
Location: NL

Post by JRz »

nikos wrote:this is a masterclass in over-engineering!
what about making a "batch" file (ctrl+A, ctrl+B) with $B end editing it?
I disagree about over-engineering (what else would you expect :) ). Your solution works for this particular folder (and is to be preferred when you only need this list once and for this folder only!!)

Mine works for any folder with any content!! So yes, it is more work to make it, but it is reusable for any folder!!

Over-engineering? I don't think so (if you need this 'command' for many folders and many times. that's the restriction)
Dumb questions are the ones that are never asked :turn:
hpp3
Member
Member
Posts: 51
Joined: 2004 Jun 04, 15:36

Post by hpp3 »

OOF!!
Guys, guys.. thanks thanks and more thanks for all the help and I think I'm due for a diploma learning about printing from a command line, but I think hiding all columns but "Name" and "Copy Columns" will do me for now. It's just that there is another file manager out there that has a handy little 'print file list' function that I found useful a couple times and had need of again, but am now using x2 (cause it's so way cool...). If such a function could be implemented for x2 I would be pleased, but it's not something I need every day. I will experiment with making User Commands or Batch files or whatever works (I'm using NT at work fer cryin' out loud...)
Once again, thanks to all
-hpp3
User avatar
fgagnon
Site Admin
Site Admin
Posts: 3737
Joined: 2003 Sep 08, 19:56
Location: Springfield

Post by fgagnon »

hpp3,
No need to hide columns if all you want is the names.
Just use Alt+C (same result as Edit | Copy names)
to paste the names of selected items to the clipboard.
(which was my first suggestion back at the top)
& of course, you would hit Ctrl+A to select all items first,
assuming you wanted them all.

nikos,
Getting a printout of selected file names (& other info) without going
through a second step of pasting to & then printing a file woud be a
nice feature to have.
I would vote to add hpp3's suggestion to the list of future features.
& I would use it, too -- not that I couldn't use Jan's code to print all files
in a folder, but because sometimes I also want to print just selected
itemnames {or columns}.

Jan,
I like your code -- not only because it's so well-thought-out for error cases,
but also because it can be easily tweaked to print subdirectories, too,
by adding the /s option.
(& re: the USB-connected printer -- I mentioned that not as an issue for myself,
but as the reason I did not offer the DOS "redirect to PRN" as a general solution
in this windows-world with USB printer proliferation.)
User avatar
JRz
Gold Member
Gold Member
Posts: 560
Joined: 2003 Jun 10, 23:19
Location: NL

Post by JRz »

fgagnon wrote:hpp3,
No need to hide columns if all you want is the names.
Just use Alt+C (same result as Edit | Copy names)
Note that you will get the full pathnames this way. So, if you want only file names without the path, you'd have to use Nikos' suggestion.
fgagnon wrote: (& re: the USB-connected printer -- I mentioned that not as an issue for myself,
but as the reason I did not offer the DOS "redirect to PRN" as a general solution
in this windows-world with USB printer proliferation.)
I knew that (at least: assumed that :) ). The word 'You' in my post wasn't meant as directed to you Fred, but in a general sense (as it is above) ;)
Dumb questions are the ones that are never asked :turn:
User avatar
nikos
Site Admin
Site Admin
Posts: 16296
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

hpp3, if you just want the names, either do the alt+C as fred said, or if you don't want the pathnames switch to list view mode first (View | pane style) and then use ctrl+P

fred the command to print directly isn't as versatile as ctrl+P. Then we'd need a different command e.g. to paste folder contents to excel!