Solved

Linking 3 batchfiles to run one after another

Posted on 2006-07-18
5
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

733 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