Solved

Linking 3 batchfiles to run one after another

Posted on 2006-07-18
5
212 Views
Last Modified: 2010-04-17
I have a batch file that xcopys from a folder to another folder.
This is the batch.
@echo off
cls
xcopy "R:\EChart\H\B*.*" "R:\Chart\Holding"

@echo on
Then i have a batch file that renames the file that i have xcopied.
@echo off
cls
Ren R:\Chart\Holding\B*.tif B???????-H.tif
@echo on

Than i have another batch file that moves the files to another folder.
@echo off
cls
Move "R:\Chart\Holding\*.*" "R:\Chart\B"

@echo on
I have to run this for every leter e.g. we have 12 folders a-n and in these folders there are letered A - Z. So i have to copy all the A's fron each of the 12 folders then rename them with the leter of the folder. the mover it to another folder called A. so in this A folder i will have files named A001-A, A001-B, A001-C and so on. Is there a way to run the first batch file and have it go to the next batch file and then run the 3rd batch file. Or could you find to put all 3 in one batch file but i would have to run in order. so i would copy the file then rename the file then move the file and do this over again 26 time for the 12 folders changing the leter each time.
Do you see what i need.
Thank you.

0
Comment
Question by:jodyreid
  • 3
5 Comments
 
LVL 15

Expert Comment

by:bpmurray
ID: 17133166
I suppose you could do something like this:

   for %%F in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ) do call file0.bat %%F

and in file0.bat, you can have:

   @echo off
   cls
   xcopy "R:\EChart\H\%1*.*" "R:\Chart\Holding"
   Ren "R:\Chart\Holding\%1*.tif" %1???????-H.tif
   Move "R:\Chart\Holding\*.*" "R:\Chart\%1"
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 17133183
I forgot to mention that if you need to preserve the separation of the commands in the three batch files, you could make file0.bat contain:

    call file1.bat %1
    call file2.bat %1
    call file3.bat %1

where you modify the batch files to use the supplied parameter, so your first file would look like:
   @echo off
   cls
   xcopy "R:\EChart\H\%1*.*" "R:\Chart\Holding"

The "%1" means the first positional parameter, in this case the letter.
0
 
LVL 2

Expert Comment

by:dMa
ID: 17137980
0
 

Author Comment

by:jodyreid
ID: 17140654
It is almost there. I need to be able change two letters in these batch files.

   for %%F in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ) do call file0.bat %%F

and in file0.bat, you can have:

   @echo off
   cls
   xcopy "R:\EChart\H\%1*.*" "R:\Chart\Holding" ''Here i need to be able change the H from A to N''
   Ren "R:\Chart\Holding\%1*.tif" %1???????-H.tif adn the same here
    Move "R:\Chart\Holding\*.*" "R:\Chart\%1"
What i have is 14 folders A - N. In each of these folders there are files named A001 an B001 and so on.all the files start with A - Z.
 What i am trying to do is take all the A's from the A folder and rename it A001-A then move them in to a new A's Folder. I then take all the A's from the B folder and rename them A001-B and do this with all folders a-z untill i have all teh A's copied, renamed and moved to the new A's folder.
Do you see what i need to do.
Thank you.

0
 
LVL 15

Accepted Solution

by:
bpmurray earned 500 total points
ID: 17141144
I think I understand. This means you need three batch files:

1. Loop through the directories and call the files
@echo off
for %%D in (A B C D E F G H I J K L M N) do call files.bat %%D

2. Loop through the file names, and call the process for each (files.bat)
@echo off
for %%F in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do call rename.bat %1 %%F

3. Rename and move according to the rules (rename.bat)
@echo off
xcopy "R:\EChart\%1\%2*.*" "R:\Chart\Holding"
Ren "R:\Chart\Holding\%2*.tif" "%2???????-%1.tif"
Move "R:\Chart\Holding\*.*" "R:\Chart\%2"
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Replace a tag with sed 2 43
topping3 challenge 14 51
python question 5 60
Microsoft C++ code failing in executable that worked 9 56
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

746 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