+ Post New Thread
Results 1 to 4 of 4
Scripts Thread, Delete certain file format using a script in Coding and Web Development; Hi how would I produce a script that would delete all .txt & .log files from a particular location please? ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    11,840
    Blog Entries
    6
    Thank Post
    592
    Thanked 1,043 Times in 920 Posts
    Rep Power
    224

    Delete certain file format using a script

    Hi how would I produce a script that would delete all .txt & .log files from a particular location please?

    Thanks

  2. IDG Tech News

  3. #2

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    8,472
    Thank Post
    889
    Thanked 890 Times in 532 Posts
    Rep Power
    596

    Re: Delete certain file format using a script

    Same as before - use VB script / AutoIT, or batch commands, type in Del /? on a command line to find out more.
    If the txt and log files are all over the place then a simpe dir *.txt or dir *.log and pipe them to a file - eg:

    dir*.txt /s>c:\textfiles.txt

    Open up the text file in excel, stick in del on every line [ after moving the cells to the right ] - save it as a cmd file and run it and bob's your uncle.....

    I would suggest you also look at powershell...

  4. #3

    Join Date
    Mar 2006
    Posts
    540
    Thank Post
    2
    Thanked 3 Times in 2 Posts
    Rep Power
    14

    Re: Delete certain file format using a script

    In VBS you would have to check all the files of a folder to see if the extension was txt or log

    Something like:
    Code:
    For Each File in Folder.Files
         if   UCASE(File.Extension) = "TXT"  or UCASE(File.Extension)="LOG"
              File.delete
         endif
    Next
    It'd probably easier to do it as a batch file.

  5. #4

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    11,840
    Blog Entries
    6
    Thank Post
    592
    Thanked 1,043 Times in 920 Posts
    Rep Power
    224

    Re: Delete certain file format using a script

    Cheers guys!

SHARE:
+ Post New Thread

Similar Threads

  1. need a script to delete shortcuts
    By philtomo-25 in forum Scripts
    Replies: 2
    Last Post: 1st November 2007, 04:50 PM
  2. Office 2007 file format support in Apache, PHP and Moodle
    By Geoff in forum Virtual Learning Platforms
    Replies: 2
    Last Post: 8th July 2007, 12:12 AM
  3. Converting VHS videos to either DVD or file format
    By ctbjs in forum How do you do....it?
    Replies: 7
    Last Post: 2nd May 2007, 02:34 PM
  4. ical file format to csv convert
    By russdev in forum Windows
    Replies: 2
    Last Post: 1st November 2006, 07:22 AM
  5. Replies: 4
    Last Post: 23rd March 2006, 07:27 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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