Quantcast

Selecting files in Windows Explorer using db data?

I have a db that contains a field with files names and what I want to do is use this field to select the files from a directory using Explorer. Anyone know if this is possible?

Problem is I have a directory with 1500 files and I need to pick out about 400 random files from it, the file names are in a db so I thought if I could just use that to do the selection it would make my life that much easier.
 

binary visions

The voice of reason
Jun 13, 2002
22,161
1,261
NC
Hmm... Do you need them selected or would it be okay to move them to a new (temporary) directory?

Here's what I would do. It's ugly and inefficient but it would work and wouldn't cause you a lot of hassle.

Export the list of files out of the database. Then, you want to add "move" before the file name and "<directory>" after the file name - there are several ways to do this. If you can export a piece of consistant data before and after the file name in the export file, you can do a search and replace - for instance, if this was music, perhaps your database contains "file type" and "bitrate" fields so each line item of your export field would read, "MP3, <file name>, 128kbps" and you could do search and replace to substitute "MP3," with "move" and ", 128kbps" with " <directory>".

If you can't do that, you could do a mail merge within Word. Just export your file names, set up a page full of mailing letters (they need to be ONE ACROSS in the column, otherwise it'll screw up your copy/paste), and merge your data in between "move" and "<directory>". Then copy and paste into a text document.

Any way you do it, you'll end up with a big page of "move <file> <directory>". Just save that as a .bat file in the directory with all of your files in it, and run it. Everything will be moved to a new temp directory.

I'm sure there's a more elegant solution but that's the first way I thought of. If you want a more specific instruction about setting up a mail merge, it's pretty easy and I can walk you through it with no trouble.
 
Hey thanks for the reply. Moving them is exactly what I need to do, right before I checked your reply I started creating a batch file. I dont do much with batch files and it just took a while for it to click. Luckily my GIS software will make it easy to tack the batch commands onto the data in each field with VB script.
 

binary visions

The voice of reason
Jun 13, 2002
22,161
1,261
NC
Excellent :thumb:

Wasn't sure what DB software you were using - some software makes customizing exports very easy, some software is stubborn and only lets you do defaults.

Gotta love batch files! I know there's a way to read in lines from a seperate file using BASIC commands, but it's been too long since I've used BASIC and researching the solution would take longer than creating an ugly batch file.