Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Output Directory Listing to File  (Read 2259 times)

0 Members and 1 Guest are viewing this topic.

rjbinney

    Topic Starter


    Adviser
  • Disarmingly Good-looking
  • Experience: Familiar
  • OS: Windows 11
Output Directory Listing to File
« on: March 21, 2006, 09:38:34 AM »
Hey all:

I want to create a way to quickly create a TXT file with a list of a subdirectory's files.

I know I can manually go through the cmd prompt and do

dir >whatever.txt

But that's not my idea of "quick".

What I did was create a batch file:

@echo off
dir %1 /-p /o:gn /b> "subdir.txt"
exit


...which I can then access by right clicking on a subdirectory.

What I'd like to do is change the "subdir.txt" part to either automatically name the new file after the subdirectory, or if that can't be, prompt me for a name.

So, what happens right now is:
Let's say I have three subdirectories in a My Documents:
  • Documents 1
  • Documents 2
  • Spreadsheets
When I go to My Documents, I right-click on "Documents 1", and it creates a new file called "subdir.txt" in the My Documents folder. If I right-click on "Documents 2", it will overwrite "subdir.txt" with the new content.[/i]

What I'd like to do is right-click on "Documents 1" and get a file back called "Documents 1.txt" or "DOCUME~1.txt" or at least a prompt for what to call it.

Is that do-able?

Thanks!
Dan: You're gonna need to get someone to fix my computer.                     Kim: What's wrong with it?                     Dan: It's in several pieces on my floor.

pomahony2

  • Guest
Re: Output Directory Listing to File
« Reply #1 on: March 22, 2006, 02:22:00 PM »

I have a similar problem.

I want to manually send multiple dir listings to a single file.

I use   dir > C:\my-file.doc, and this is ok!
But when I do it to the next dir, it  OVER-WRITES writes the first file.
--
I am looking for a simple command at the end of the command string that would allow me to "append" or add it to the current file.
--
I am an old Cobol programmer and it seems to me that years ago, that there was a way to do this in DOS.
--
Pat O'Mahony   [email protected]

end of message


2k_dummy



    Specialist
  • A word, once spoken, can never be recalled.
  • Thanked: 14
    Re: Output Directory Listing to File
    « Reply #2 on: March 22, 2006, 03:09:42 PM »
    Use >> to append to a file
    If you don't stand for something, you'll fall for anything.
    _______________________________________ ________
    BlackViper

    Software and utilities

    rjbinney

      Topic Starter


      Adviser
    • Disarmingly Good-looking
    • Experience: Familiar
    • OS: Windows 11
    Re: Output Directory Listing to File
    « Reply #3 on: March 22, 2006, 07:07:09 PM »
    That worked perfectly; fit the bill... I'd still like to know if there's a way to automatically name a file after its subdirectory?

    Thanks
    Dan: You're gonna need to get someone to fix my computer.                     Kim: What's wrong with it?                     Dan: It's in several pieces on my floor.