Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


deleting duplicat files in a directory

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> deleting duplicat files in a directory
  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 >>
 deleting duplicat files in a directory - 11/15/2008 11:38:18 PM   
  magmanrule

 

Posts: 2
Score: 0
Joined: 11/15/2008
Status: offline
This is my first post, I have been trying to figure this out for a bit with no success. Any help would be greatly appreciated.Thanks
I have a directory, C:/U2 that contains files with the extensions ".txt" and ".parse".
The files in this directory can have duplicate names except for the extension.
example:
"primary 58787.txt"
"primary 58787.txt.parse"
I need to loop through the list of files to find duplicates and delete the ones with the .txt only.
( "primary 58787.txt" in this example)
 
 
Post #: 1
 
 RE: deleting duplicat files in a directory - 11/16/2008 4:31:07 AM   
  ebgreen


Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
What have you tried so far?

_____________________________

"... 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 magmanrule)
 
 
Post #: 2
 
 RE: deleting duplicat files in a directory - 11/16/2008 9:44:28 AM   
  ehvbs

 

Posts: 2224
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi magmanrule,

start with one sentence to describe your task to a willing but not very bright person:

Please delete each file "<name>.txt" from the directory "c:\u2" for which there is
a file "<name>.txt.parse" in that folder.

Then you can plan a loop over all files in that directory

  For Each oFile In <TheFolder>.Files
  Next

you need an IF to concentrate on the .txt.parse files:

If ".txt.parse" =  ?How to get the tail of oFile's Name? Then
     delete file HeadOfName + ".txt"
End If

Check if deleting the files in the loop works - if not, consider collecting
the files to delete in an array or dictionary.

Use the VBScript Docs; start with FileSystemobject.

Good luck!

ehvbs

(in reply to magmanrule)
 
 
Post #: 3
 
 
 
  

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 >> deleting duplicat files in a directory 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