469,579 Members | 1,112 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

Need to write a batch file to rename lots of folders

I've never really written batch files before and don't know syntax etc so am looking some help. My folder structure is as follows:

c:\applications\ contains a list of folders for example:

c:\applications\100000\ , c:\applications\200000\ etc

and in each of these folders there are lists of folders named by the applications primary key, for example:


Basically the problem I have is that the primary key is wrong for each one as it uses a primary from a different database. Therefore each folder name will need to be updated. There are thousands of applications so I'd have to query the application_number from test database using primary key then query the live database with the application_number to get the new primary key. This is unfeasible so I need a batch file to do this for me.

The following are the list of steps that it'd need:

for each folder in c:\applications\
for each folder in c:\applications\<foldername>
sqlplus <user>/<password>@<test_database>;
select application_number from applications where pk = <foldername>;
variable appNumber = application_number;
exit; //close test database

sqlplus <user>/<password>@<live_database>;
select pk from applications where application_number = appNumber;
int folderName = (pk / 1000) * 1000; //turn 153242 into 100000
new folder c:\applications\<folderName>\<pk>\application_form .pdf;
exit; //close live database

I'd appreciate any help as I've never written a batch file to do this sort of thing!
Nov 28 '08 #1
2 1251
16,027 Expert Mod 8TB
Which language are you using?
Nov 28 '08 #2
3,112 Expert 2GB
Well, as it's a batch file, I guess the OP means batch scripting for Windows.

Nov 29 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by rtilley | last post: by
reply views Thread by Vijay Kumar | last post: by
8 posts views Thread by jack | last post: by
6 posts views Thread by strychtur | last post: by
1 post views Thread by SPE - Stani's Python Editor | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.