Results 1 to 6 of 6

Thread: delete all .TXT files

  1. #1
    Join Date
    Jan 2009
    Posts
    9

    delete all .TXT files

    Hello, I create a time and date stamp with a .TXT extension for 9 folders and 6 sub folders such as \1 \2 \3 \4 \5 \6 for a total of 54 folders with a time stamp.TXT

    C:\WebSite\A\1 \3 \4 \5 \6
    C:\WebSite\A\2
    C:\WebSite\B\1

    I would like to delete all the .TXT records within the structure.
    I have tried many ideas without success and the last one should have worked;

    Del C:\Webs\*.txt /S

    Please advise me as to how to get the deletion to work?
    Mehran

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: delete all .TXT files

    DELETE
    FROM tblRecordsWithColors
    INNER JOIN tblOldCopiesOfUpdatedRecords ON tblRecordsWithColors.FILE_NBR = tblOldCopiesOfUpdatedRecords.oldFILE_NBR
    WHERE (((tblRecordsWithColors. FILE_NBR)=[tblOldCopiesOfUpdatedRecords]![oldFILE_
    NBR]));

  3. #3
    Join Date
    Dec 2008
    Posts
    183

    Re: delete all .TXT files

    You may use the following the VB program to clean all your files from the system.

    Code:
    Option Explicit 
     
    Sub cleanTxt() 
         
        Dim i As Long 
        Dim lastrow As Long 
         
         turn of screen refresh for  speed
        Application. ScreenUpdating = False 
         
         get last row of data Col A
        lastrow = Range("A65536").End(xlUp).Row 
         
         format all as general
        Range(Cells(1, 1), Cells(lastrow, 1)).NumberFormat = "General" 
         
         from lastrow to Row 1
        For i = lastrow To 1  Step -1 
             test is text or blank
            If Not IsNumeric(Cells(i, 1)) Or Cells(i, 1) = "" Then 
                 delete if text or blank
                Cells(i, 1).EntireRow.Delete 
            End If 
             leave if number
        Next i 
         
         turn on screen refresh
        Application.ScreenUpdating = True 
         
    End Sub

  4. #4
    Join Date
    Apr 2008
    Posts
    193

    Re: delete all .TXT files

    To delete all the .TXT flle here is some code apply it and check whether it deletes all the .TXT file.

    Code:
    Option Explicit
    Set fsobj = CreateObject ("Scripting.FileSystemObject")
    if (fsobj.FileExists ("g:\test.txt")) then fsobj.DeleteFile ("g:\test.txt")
    
    //rem program continues here
    
    /*If you need to do additional tasks when you delete the file, then you use the block form of the IF statement:*/
    
    Set fsobj = CreateObject ("Scripting.FileSystemObject")
    if (fsobj.FileExists ("g:\test.txt")) then
    fsobj.DeleteFile ("g:\test.txt")
    rem run some additional code
    end if

  5. #5
    Join Date
    Jan 2009
    Posts
    9

    Re: delete all .TXT files

    I am sorry that I gave you the wrong idea that the data was in a table.

    My data is in folders such as below;
    C:\WebSite_01\FolderA\File1.txt
    C:\WebSite_01\FolderB\File2.txt
    C:\WebSite_01\FolderC\File1.txt
    C:\WebSite_01\FolderD\File2.txt
    C:\WebSite_01\FolderE\File1.txt
    C:\WebSite_01\FolderF\File2.txt

    C:\WebSite_02\FolderA\File1.txt and repeat the folders as above 9 times.

    I would like to delete the time stamp.TXT records from all of the 54 folders.

    Thank you
    Mehran

  6. #6
    Join Date
    Aug 2004
    Location
    India
    Posts
    76

    Re: delete all .TXT files

    Quote Originally Posted by Stockholm View Post
    I am sorry that I gave you the wrong idea that the data was in a table.

    My data is in folders such as below;
    C:\WebSite_01\FolderA\File1.txt
    C:\WebSite_01\FolderB\File2.txt
    C:\WebSite_01\FolderC\File1.txt
    C:\WebSite_01\FolderD\File2.txt
    C:\WebSite_01\FolderE\File1.txt
    C:\WebSite_01\FolderF\File2.txt

    C:\WebSite_02\FolderA\File1.txt and repeat the folders as above 9 times.

    I would like to delete the time stamp.TXT records from all of the 54 folders.

    Thank you
    Mehran
    Can't you delete the files from folders manually? Why are you asking for help for just a silly question? If you can't do so then please mention what exactly the problem is?
    LOOK FOR VARIOUS WINDOWS SOFTWARE'S AND NETWORKING & SECURITY SOLUTIONS OVER HERE

Similar Threads

  1. Replies: 7
    Last Post: 04-05-2012, 12:37 PM
  2. Cannot delete MP4 files
    By The!Winston in forum Operating Systems
    Replies: 7
    Last Post: 30-03-2012, 01:44 PM
  3. Replies: 5
    Last Post: 12-11-2011, 10:22 PM
  4. Not able to delete files in MAC
    By Paisley007 in forum Operating Systems
    Replies: 5
    Last Post: 05-02-2010, 12:53 PM
  5. How To Delete Files Which Windows Wont Delete?
    By Hardik in forum Windows Software
    Replies: 2
    Last Post: 06-03-2007, 12:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,384,447.17776 seconds with 16 queries