Renaming files from database records

Posted on 2007-11-15
Last Modified: 2010-04-30

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.

Question by:mrkipling
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 14

Accepted Solution

_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.


* 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

LVL 25

Expert Comment

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

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

688 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