Results 1 to 5 of 5

Thread: [RESOLVED] Delete all files containing specific string

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    111

    Resolved [RESOLVED] Delete all files containing specific string

    Hello

    I'd like to ask how can i delete all files in a specific directory which contains a specific string?
    Would you please post a code for that?

    Thanks
    Cheers
    Adel

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Delete all files containing specific string

    Are these all text files?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    111

    Re: Delete all files containing specific string

    yes, they are all text files

    I meant that they contain specific string in their names.. sorry i was not very clear

  4. #4
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Delete all files containing specific string

    Code:
    Dim FolderName As String
    Dim PartOfFileName As String
    Dim FileName As String
    
    FolderName = "C:\YourFolder\"
    PartOfFileName = "abcxyz"
    FileName = Dir(FolderName & "*" & PartOfFileName & "*.*")
    Do While FileName <> ""
       Kill FolderName & FileName
       FileName = Dir()
    Loop
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    111

    Re: Delete all files containing specific string

    Thanks it works like a charm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width