Author Topic: Directories to text file  (Read 3415 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7529
Directories to text file
« on: December 08, 2005, 05:13:20 PM »
I know there are many ways to dump a bunch of dir\subdir structures to a text file, but do any of you know how to limit the list to only include......say up to directories 3 deep? I wasn't sure where to post this question and I definitely don't need a lisp answer.

Thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Directories to text file
« Reply #1 on: December 08, 2005, 05:19:00 PM »
I guess you could see how many backslashes you get at the beginning when you select your main directory, and the run your program until you reach that number plus three for all other directories listed.

Just an idea.
Tim
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Directories to text file
« Reply #2 on: December 08, 2005, 07:31:30 PM »
Well I solved this with a not so elegant roundabout way :).

1. Dumped directories to text file.
2. Replaced the O:\ with ' and removed all spaces.
3. Replaced \ with a tab using ^t.
4. Imported text file as tab delimited into excel.
5. Deleted column d and any column after that.

Joila..... a list only 3 dirs deep!

Good night,

Ron


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

M-dub

  • Guest
Re: Directories to text file
« Reply #3 on: December 08, 2005, 08:16:22 PM »
I think Directory Printer does that, but I can't be certain until I get to work tomorrow.  It's a great program to have anyway.  Even if it doesn't work for you this time, it will come in handy sometime, for sure.
I'll try it tomorrow...

M-dub

  • Guest
Re: Directories to text file
« Reply #4 on: December 08, 2005, 08:18:27 PM »
Oh, there it is...Yep, it'll do that.

 Directory Printer enables you to print or export directory listings, a capability which is not provided by Windows itself. Features include:

Quote
    * Print single directories or entire trees. When printing trees, the number of levels of subdirectories printed can be specified.
    * Choice of fields to print (long and short file name, file type, size, date/time, attributes, version information, MP3 artist/title/duration, MS Word/Excel title/subject/author).
    * Sort by name, extension, file type, date/time or attributes
    * Prints total number and size of files.
    * Option to print summary listing (subdirectories only, without files).
    * Option to filter files by date.
    * Print in any of three different column formats, using any available font.
    * Ability to export to ASCII text, HTML, or comma-delimited files (which can be imported into word processing, spreadsheet or database programs).
    * Print preview available.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Directories to text file
« Reply #5 on: December 08, 2005, 08:21:25 PM »
in a batch file ...

Code: [Select]
dir /a /s /o > textfile.txt
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Peter Jamtgaard

  • Guest
Re: Directories to text file
« Reply #6 on: December 09, 2005, 09:05:57 AM »
maybe a lisp solution

like: (getdirectories "c:/acad/lisp/" 3)

You could also change it to take the output filename as an argument.

Code: [Select]
(defun GetDirectories (strPath intLevel / filOut)
 (vl-load-com)
 (setq filOut (open "DIRS.txt" "w"))
 (getSubDirectories strPath intLevel)
 (close filOut)
)
(defun GetSubDirectories (strPath intLevel / lstDirectories strDirectory strPath2)
 (if (> intLevel 0)
  (progn
   (setq lstDirectories (vl-directory-files strPath nil -1))
   (if lstDirectories
    (foreach strDirectory lstDirectories
     (if (and (/= strDirectory ".")
              (/= strDirectory "..")
              (/= strDirectory nil))
      (progn
       (setq strPath2 (strcat strPath strDirectory "/"))     
       (write-line strPath2 filOut)
       (getSubDirectories strPath2 (1- intLevel))
      )
     )
    )
   )
  )
 )
)

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Directories to text file
« Reply #7 on: December 09, 2005, 09:40:37 AM »
Thanks for all the replies. The free program I have been using to create these lists is called JR Directory Print.
http://www.spadixbd.com/freetools/jdirprint.htm

It's a great little standalone program. No installer:)

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Directories to text file
« Reply #8 on: December 09, 2005, 10:01:33 AM »
I think Directory Printer does that, but I can't be certain until I get to work tomorrow.  It's a great program to have anyway.  Even if it doesn't work for you this time, it will come in handy sometime, for sure.
I'll try it tomorrow...

That's a slick program :).

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

M-dub

  • Guest
Re: Directories to text file
« Reply #9 on: December 09, 2005, 10:06:08 AM »
I use it for all kinds of stuff.  It's great for creating scripts.  The way I do it, anyway.  Export to csv is really nice.