?
Solved

Linking 3 batchfiles to run one after another

Posted on 2006-07-18
5
Medium Priority
?
228 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …
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 …
Suggested Courses

771 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