Solved

Linking 3 batchfiles to run one after another

Posted on 2006-07-18
5
227 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Six Sigma Control Plans

729 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