Solved

Renaming files from database records

Posted on 2007-11-15
2
144 Views
Last Modified: 2010-04-30
Hi,


I am just about to start a small file renaming project with the following requirements:

Provide a front end for users to select a specific directory from a dir structure.

Rename the files in that dir by looking up the existing filename in  a ms sql db table, and renaming the file with a string from a different column in the corresponding db record.

This is my very basic train of thought on the project:

start loop

loop through each file

create a recordset using the filename as criteria to return the required string.

rename file with new name.

Does this seem correct ?

Do I place the recordset inside the loop so it returns the correct string for each file name ?

As you can guess coding is not a strong point, so any advice is greatly appreciated.

Thanks
0
Comment
Question by:mrkipling
2 Comments
 
LVL 14

Accepted Solution

by:
_Stilgar_ earned 100 total points
ID: 20296961
You could create the recordset and loop through it, renaming the files by the fields as parameters, that way you only access the db once.

So:

* fetch all records from files table in db
* start loop
    * for each record in the recordset: change file rs("filename") to be rs("filename_new")
* end loop

Stilgar.
0
 
LVL 25

Expert Comment

by:kevp75
ID: 20309807
* fetch the folder from the database
* start loop
    * for each file in the rs(folder) rename filex.ext to filey.ext   (use FSO move to do this)
* end loop
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question