473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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:

c:\applications\100000\154523\application_form.pdf
c:\applications\100000\128042\application_form.pdf
c:\applications\200000\274398\application_form.pdf
etc

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 1329
acoder
16,027 Expert Mod 8TB
Which language are you using?
Nov 28 '08 #2
Nepomuk
3,112 Expert 2GB
Well, as it's a batch file, I guess the OP means batch scripting for Windows.

Greetings,
Nepomuk
Nov 29 '08 #3

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

Similar topics

15
by: Viviana Vc | last post by:
How can I programatically do the equivalent of the following: cacls "C:\Program Files\test" /T /G Everyone:f ? Thanks, Viv
10
by: rtilley | last post by:
Hope it's not inappropriate to post this here. Could someone critique my code? I have no Python programmers in my office to show this to. The script works OK, but should I do it differently? I...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
0
by: Vijay Kumar | last post by:
Hi, I have a batch file(test.bat) i wrote a command to rename a text file in this batch file. Both batch file and text files are in Network Shared Drive. I am trying to run that batch file from...
0
by: Raakish | last post by:
Hello I am trying to use a batch file to run a DTS program that I had created. Below is the Batch File code: REM Type: Batch File REM Created by: Raakish REM Contact: raakish22@gmail.com REM...
8
by: jack | last post by:
Hi, I have more than 1000 photos in my system but with very untidy name. Im trying to create a program through which i can rename the file. I have seen the examples on net an forums, but the...
6
by: strychtur | last post by:
Ok, I don’t have any code that does archiving. The way it works here is users get project emails sent to their inbox. Then they move the emails to the corresponding project on a drive in an email or...
1
by: SPE - Stani's Python Editor | last post by:
Phatch is a simple to use cross-platform GUI Photo Batch Processor Phatch handles all popular image formats and can duplicate (sub)folder hierarchies. It can batch resize, rotate, apply...
2
rhitam30111985
by: rhitam30111985 | last post by:
Hi all .. i came across the findstr batch command for searching for specific string in a file name . Can the same be used for reading folder names ? ie i have folders like these : 2008-001...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.