Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Create a file that has the directory structure and files of a particular folder

Posted on 2006-11-22
11
Medium Priority
?
893 Views
Last Modified: 2008-02-07
I need to create a file which has, in text, the directory structure and files of a particular folder.

I have no clue as to where to begin on this process.
0
Comment
Question by:rpong
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 18000179
You could just type:

dir x:\path\to\list\structure\of /s /b >c:\file-structure.txt

This will store a list of every file and it's complete path in the file c:\file-structure.txt
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 18000287
You could also use tree:

tree  
0
 

Expert Comment

by:thirtysomething
ID: 18000289
Another option is tree /f x:\path\to\list > c:\treeoutput.txt

To get printable characters use tree /f /a

Ps you have to run this from the command prompt, Ie Start -> Run -> type in cmd
You will now be at the command prompt so you can type
tree /f c:\  > c:\treeoutput.txt


J

0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 30

Expert Comment

by:SteveGTR
ID: 18000296
I was going to elaborate on the /f syntax when I gafted and hit the enter key. It looks like thirtysomthing's submission :)
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18001415
xcopy /l /s somedirectory >listfile.txt

Will do the trick, as well.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18001898
And just to be awkward another way:

for /r Z:\ %a in (*) do @echo %a >> dirlist.txt

I'd got with tree though myself :-)

Steve
0
 
LVL 39

Accepted Solution

by:
BillDL earned 2000 total points
ID: 18003410
I use a simple freeware program that adds a right-click menu option and is able to output a visual tex-based structure very similar to the TREE command (using the options given by thirtysomething), but creates long filenames.  The DOS TREE command outputs file and foldernames as abbreviated DOS 8.3 names.  Obviously if you are using any command in full DOS (ie. not the "DOS" in Windows 2000/XP), it will create short filenames.

If you're working in full DOS, then the utility I suggest wo't be any good to you anyway.

The utility is discussed here, but ia download would require registration:
http://www.pcmag.com/article2/0,1759,1560656,00.asp

Here is a live link for you to download version 1.0.  The version I used in Win98 (works in Win2K and XP) was version 1.1, but I can't see any difference.

http://users.ev1.net/~jsigno/addon/Treeprt.zip

It installs cleanly, and the Add/Remove Programs removes the shellextension files and registry entries cleanly.  To use, just Right-Click a folder or drive and first choose "TreePrint" > Options.  Configure it to No Limit on Folder Levels, and tick the boxes to include filenames.  Sort-order is a user preference, as is the default editor (default is notepad).  Now use the "Save" Right-Click option, browse to your destination directory, and type in a file name.

Here's a sample of the output, although I don't know how it will be rendered in this page:

TreePrint listing of: C:\Program Files\Microsoft Office

C:\Program Files\Microsoft Office
+----CLIPART
|    +----PUB60COR
|    |         AG00004_.GIF

etc

|    |         WING2.WMF
|    |         WNTER_01.MID
|    |    
|    \----Publisher
|         \----Backgrounds
|                   J0143743.GIF
|                   J0143744.GIF
|                   J0143745.GIF

etc.

|              
+----MEDIA
|    +----CAGCAT10
|    |    |    CAGCAT10.DLL
|    |    |    CAGCAT10.MMW
|    |    |    ELPHRG01.WAV

etc
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18003502
Tree in XP gives full long directory and filenames...

Steve
0
 
LVL 39

Expert Comment

by:BillDL
ID: 18005878
Steve.  Thanks for that, and don't I feel dumb.

You see, I've never really used the native tree command in Windows XP, only in Win9x using the old DOS 6.22 version made compatible using setver.  I was aware it existed as a native command in XP though, so I ran the tree command on the WinXP system I was using, and surprisingly it output 8.3 names.  What I stupidly hadn't spotted was that the drive I had used as the target was the external usb drive I had been using to recover data from a Win98 hard drive that had had its directories screwed up by DOS Scandisk, and had all the directories and files in 8.3 names, so I assumed that the behaviour was the same as the old DOS command .  Doh!! :-)

Now that I have had my halfwittedness pointed out to me so delicately, I've now dispensed with the program I suggested and have the following shortcut ("Tree List Here" - target as C:\CMD_FILES\TreeList.cmd) in my "SendTo" folder and set to run minimized:

@echo off
tree /a /f %1 > %1\_TreeListing.txt
exit

In fact, I think I'll use this instead (C:\CMD_FILES\TreeList.cmd):

@echo off
tree /a /f %1 > %TEMP%\TmpList1.txt
type %TEMP%\TmpList1.txt | find /i /v "Folder PATH listing" > %TEMP%\TmpList2.txt
type  %TEMP%\TmpList2.txt | find /i /v "Volume serial number" > %TEMP%\TmpList3.txt
echo CONTENTS OF %1 DIRECTORY > %1\TreeListing.txt
echo. >> %1\TreeListing.txt
type %TEMP%\TmpList3.txt >> %1\TreeListing.txt
del %TEMP%\TmpList*.txt > nul
exit

*.REG file to merge to Registry and add new Right-Click Menu for Folders and Drives:

----------- start of text to copy (DON'T copy this line) -----------
REGEDIT4

[HKEY_CLASSES_ROOT\Directory\shell\List]
@="TreeListing Here"

[HKEY_CLASSES_ROOT\Directory\shell\List\command]
@="C:\\CMD_Files\\TreeList.cmd \"%1\""

[HKEY_CLASSES_ROOT\Drive\shell\List]
@="TreeListing Here"

[HKEY_CLASSES_ROOT\Drive\shell\List\command]
@="C:\\CMD_Files\\TreeList.cmd \"%1\""

----------- end of text to copy (DON'T copy this line) -----------

Quite handy to right-click a folder or drive and Send to "Tree List Here" or use the static context menu option "TreeListing Here".

Still can't believe how dumb I was :-(
0
 

Author Comment

by:rpong
ID: 18021473
Thanks for all the different ways to accomplish this.

I appreciate all the responses
0
 
LVL 39

Expert Comment

by:BillDL
ID: 18024968
Thank you, rpong.
I don't like to sound unappreciative, but I feel rather guilty accepting these points.
You see, the "TreePrint" program I suggested actually outputs the same (the minor differences are unimportant) visual structure as the TREE command originally suggested by SteveGTR and thirtysomething, if used with the /f /a switches.

I'm not sure whether you read my earlier comment in which I explained my wrong assumption about the TREE command outputting short filenames.  My follow-on comment was just some additional detail explaining how to use the command on a repeat basis from Windows Explorer without having to type out the command in a CMD window repeatedly.

Fair enough, if you find the TreePrint program useful, then it is worthy of inclusion in the points, but I would really have preferred a share in a points split along with the others who suggested alternative "DOS" solutions.

The decision is obviously yours, but if you reconsider I have absolutely no problems with you asking an administrator to reopen the question and allowing you to finalize the question with a points split.

Regards
Bill
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question