PDA

View Full Version : Parsing TXT file (WXP-Pro)



dredlelay
11-10-2005, 12:26 PM
I have a text file that looks like this (below). I used the command prompt to list all the files I have on my computer into this text file. Below is just a sample from it. What I'm trying to figure out is how to parse it and extract lines that are older than 3 years from today's date and write to a new file. If anyone can script this for me that would be really great. If not, any direction would be great as well. Thanks so much.

This is what it looks like in the current text file:
-------------------------
Directory of X:\

11/08/2002 05:09 PM <DIR> etc
11/04/2001 12:06 PM <DIR> home
11/01/1995 11:29 AM <DIR> home1
04/07/2000 09:47 AM 41 New Text Document.txt
04/05/2005 01:47 PM Symposium.bak
1 File(s) 41 bytes

Directory of X:\etc

11/08/2005 05:09 PM <DIR> .
05/19/2005 06:15 PM <DIR> ..
11/06/2005 12:00 AM <DIR> log
08/24/2005 05:49 PM <DIR> modules
11/08/2005 05:09 PM 30,878 registry


What I need to accomplish is below:
------------------------------

Directory of X:\

11/08/2002 05:09 PM <DIR> etc
11/04/2001 12:06 PM <DIR> home
11/01/1995 11:29 AM <DIR> home1
04/07/2000 09:47 AM 41 New Text Symposium.bak
1 File(s) 41 bytes

Directory of X:\etc
------------------------------

cprasley
04-11-2006, 03:56 PM
I'm not entirely clear about what you are trying to do. Are you just trying to find files more than 3 years old? If so then it would be easier to walk the directory tree within the VB/JS script and compare the date using the FileSystem object rather than trying to parse dates from the directory listing. It would also allow you to format the output so that it's easier for whatever comes next. For example, if the next step is to rename or move the file then having an absolute pathname would be easier than listing the parent directories one at a time.