Search code examples
batch-filecmddir

CMD Command Prompt DIR Batch File


I Have a batch file I created below:

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
S:
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
PAUSE

I would like to know if anyone can help me get closer to having the header and footer removed from a dir > dir.txt. I cannot use bare format bc I use the date created, modified, and accessed to monitor each project. I then import these text files into Excel. I am curious if there is a way to do this with a batch, so I will not have to cull the text files each time in Excel.


Solution

  • Pipe it into a findstr with regular expressions so that it pulls lines starting with a number (dates are the first column in the default directory listing). Something like this:

    dir "S:\Project Folder 2014\Projects" | findstr /R "^[0-9]" > S:\MyFolder\dir01.txt