Solved

Renaming files from database records

Posted on 2007-11-15
2
139 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
Comment Utility
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
Comment Utility
* 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now