Saturday, March 25, 2017

windows - CMD Command Prompt DIR Batch File


  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
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

***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?

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...