Solved

Renaming files from database records

Posted on 2007-11-15
2
140 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Formula problem with Excel attachment 6 27
how to Classify of email (pdf attachments) 7 36
ASP/VB email question 4 35
key press alert 2 18
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 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