Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy all drive files (*.jpg) to a folder 1

Status
Not open for further replies.

keeping

Technical User
Jun 14, 2009
3
CA
Hello All,

I am very green with VB 6.0, so i appologize in advance. I am trying to figure out how to write a VB code to scan a particular extension (i.e. *.jpg or *.doc) on my entire hard drive (C:) including subfolders and copy them to a single folder on the computer or a USB drive. i want to be able to change the extension as needed (can be done in code) or if it is possible be able to copy multiple extensions through the coding, also a completion message would be really nice. Hopefully this is possible.

Thanks in advance
 
They're all perfectly possible (I'm writing something myself at the minute that does 95% of what you want), but it's a bit of a large scope for a single question.

What particualr bits are you having trouble with?



HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
thanks for replying, i am not sure where to start so i havent even did anything yet besides searching the internet for help and ideals
 
OK, first point is what language you want to code this in. Do you want to use VBScript or VB6?

Next point, break it down into easily identifiable points e.g.

You need to know how to loop through files in a given folder and it's subfolders.

You need to idetify if the file is of the type you're looking for (by it's extension).

You then need to know how to copy the file to a specified folder.

You need to find out how to message the user that it's finished (unsuprisingly this is the easiest part).

It would be worth deciding which of these is the priority for you to learn and then ask about them (the posters here will help with particular problems but a whole code solution is not going to help you learn anything).

Also you say you want to change the file extension, I'm assumning this is the searched for file extension? Is that correct?

Regards

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 

I would also add:
What do you want to do when you find the same file in two (or more) different location? Maybe different versions of the same file. You can not have more than one file with the same name in one folder.

Have fun.

---- Andy
 
For a task like this you might look at DirReaderObject for handling your disk scanning to find the files. It can accept a pattern like "*.jpg" to limit the hits, and since it returns an ADO Recordset you can use .Filter on the result to narrow things further.

Using .Sort on the Name and Extension fields can help you detect duplicate filenames if required.

There is nothing there you can't write yourself in VB6, but it saves you the trouble.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top