1. I use CMD to create a text file for a directory of directories (ie. 2014 Folder containing folders for each project that year).

  2. Piping the DIR command to create a text file is very useful, but would love to automate the process as much as possible.

  3. I import the text file into Excel to cull the data.

  4. I am curious if there is a way to remove the Header and Footer (along with the folders named <.> and <..> b/c I'm not sure what they even are).

  5. But would like to know if this is possible before the text file hits Excel.

  6. I have come close with my current batch, but it leaves two blank rows at the top; which may not be a big deal, but I would like to know the best way possible.

*It seems this could be a very common situation, I just cannot find a specific batch w/o being to complex for my understanding.

**My current batch file uses this type of approach: DIR, REN (for whatever reason to modify the old file into a new one) and FINDSTR /V "Volume Directory .. bytes" dir01.txt.old > dir01.txt

TITLE Project Folders 
DIR S:\"Project Folder 2014\Projects" /T:C /O:-N > S:\MyFolder\dir01.txt 
DIR S:\"Project Folder 2014\Projects" /T:W /O:-N > S:\MyFolder\dir02.txt 
DIR S:\"Project Folder 2014\Projects" /T:A /O:-N > S:\MyFolder\dir03.txt 
CD MyFolder 
REN dir01.txt dir01.txt.old 
REN dir02.txt dir02.txt.old 
REN dir03.txt dir03.txt.old 
FINDSTR /V "Volume Directory .. bytes" dir01.txt.old > dir01.txt 
FINDSTR /V "Volume Directory .. bytes" dir02.txt.old > dir02.txt 
FINDSTR /V "Volume Directory .. bytes" dir03.txt.old > dir03.txt 
DEL dir01.txt.old dir02.txt.old dir03.txt.old 

***Please advise!

The bare format will not be useful; as I use the date created, modified, and accessed in 3 separate text files to use for tracking the projects

Would this be easier to accomplish in PowerShell?

  • Please show us your batch file, and do clarify what you really are after with this. Giving some kind of a example of the files and subfolders would also make it easier to answer.
    – zagrimsan
    Sep 18 '15 at 14:41
  • CMD is not very nice to do complex things with, so if you know PowerShell it might be easier to get good results with it.
    – zagrimsan
    Sep 18 '15 at 14:43
  • Yeah, I figured. I just learned about CMD before PowerShell; so it's what I feel more comfortable with at the time and it seems more simple.
    – MLowry54
    Sep 18 '15 at 14:47
  • I copied the code to the question body where it is easier to format things. (the edit might not be visible immediately due to moderating)
    – zagrimsan
    Sep 18 '15 at 14:52
  • 2
    Why do you ask the same question?
    – JosefZ
    Sep 18 '15 at 15:39

I used findstr /R "^[0-12]" as per Marc answer at SO, so I guess b/c the date(month) is the start of each line I need; minus the two folders named [.] and [..]. But this will suffice. Thanks again!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.