473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Searching for files

14
Hi

I need the code that will look in a folder for all the files that have the same file extension and then to delete/remove all these files

Thanks

Sanka
Oct 2 '07 #1
1 931
Killer42
8,435 Expert 8TB
Although the FileSystemObject model is probably the better way to go, a very simple method is to use the old Dir() function, like so...

Please be careful playing with this sample code. Since it deletes files, it could have serious consequences.

Expand|Select|Wrap|Line Numbers
  1. Dim FileName As String
  2. Dim FolderName As String
  3. FolderName = "C:\Temp\"
  4. FileName = Dir(FolderName & "*.Txt")  ' Get first matching file.
  5. Do While FileName <> ""
  6.   Kill FolderName & FileName
  7.   FileName = Dir()  ' Get next matching file.
  8. Loop
Oct 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John | last post by:
Hi everyone ! This is a first time I post a message here. If I post my message in a wrong group. Please ignore it. I am trying to build a website which allows users (can be thousands of...
4
by: ADE | last post by:
Hi I was wondering if one of you could help me out I would like for this function to be able to find file names as well instead of printing out every file that ends with a .jpg or .gif extension...
3
by: Ma Xiaoming | last post by:
Dear ladies and gentlemen, As you know, by building a Smart Device Application in Microsoft Visual Studio .NET 2003, we could create a project for Pocket PC. My question is: How to search...
2
by: Paul Bromley | last post by:
Can someone give me a pointer of the best way to show that an application is busy and has not locked up? I am writing a utility to search a network drive for a number of tiff files. I will...
29
by: jaysherby | last post by:
I'm new at Python and I need a little advice. Part of the script I'm trying to write needs to be aware of all the files of a certain extension in the script's path and all sub-directories. Can...
1
by: Christian Münscher | last post by:
Hi Group! Here I have a big chaotic web-project where all 500 files are lying around in on directory without any structure. On the content-level there is a structure, the whole thing is divided...
5
by: bir | last post by:
I have a folder which contains the xml files with the word CICM in the filename (can also contain some other files) I need to search for all these xml files and create a single zip file for all...
11
by: jonathan184 | last post by:
script to search for keywords in files in a dir Basically the script consists of a file with part numbers I got a dir with files I want to search the files line by line and if a line has the...
1
by: SSJVEGETA | last post by:
Hello, everybody. I have read some examples and manuals for the egrep command for Linux and I don't know if this egrep command is right for the particular files I am searching for. Here is what the...
6
by: bushwacker | last post by:
Hello all, I'm a chemical engineering student. our teacher has given us a project to do some calculations based on some equations. those equations include constants, which are to be read from a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.