Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


File comparison

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,31402
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> File comparison
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 File comparison - 2/21/2006 11:58:41 PM   
  Yukon2005

 

Posts: 0
Score: 0
Joined: 2/21/2006
Status: offline
Hey all,

I have a question regarding file comparison or string matching... I have a directory full of files that I would like to copy to a "working" folder else move to a "corrupted" folder.

All of the file names have the following structure:

{Username}_{Date}_{Section Type}.txt

JoeSoap_28032006_SectionOne.txt and JoeSoap_28032006_SectionThere.txt or
PietS_13052006_SectionOne.txt and PietSnot_13052006_SectionThere.txt

In theory there should always be two files, "SectionOne.txt" and "SectionThere.txt"

Each filename is unique, i.e. there will always only be one of eah file. Now... I would like to return all the files ending with "Section1.txt" and then find all the "Section2.txt" files associated with the "Section1.txt" file.

Section1 FileName                                |    Section2 FileName                                     |    Action
JoeSoap_28032006_SectionOne.txt    |    JoeSoap_28032006_SectionThere.txt    |    Move to "Working" folder.
PietSnot_13052006_SectionOne.txt    |                                                                     |    Move to "Corrupted" folder.
                                                             |    PietSnot_13052006_SectionThere.txt    |    Move to "Corrupted" folder.
etc.....

Could anybody please point me in the right direction on this. It's pretty urgent I haven't been able to figure it out.
 
 
Post #: 1
 
 RE: File comparison - 2/22/2006 2:46:02 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Here is how I would go about it. Note that this presumes that all the files in the folder are named along the guidelines you presented. If this may not be the case, then you will need to add code to skip files that do not:

      

One more note is that the example data you gave:

Section1 FileName                                |    Section2 FileName                                     |    Action
JoeSoap_28032006_SectionOne.txt    |    JoeSoap_28032006_SectionThere.txt    |    Move to "Working" folder.
PietSnot_13052006_SectionOne.txt    |                                                                     |    Move to "Corrupted" folder.
                                                             |    PietSnot_13052006_SectionThere.txt    |    Move to "Corrupted" folder.

Does not look the way I think you meant it to. In your data, both sections are present for both users so I think they should all be moved to working.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Yukon2005)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> File comparison Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts