Solved

Linking 3 batchfiles to run one after another

Posted on 2006-07-18
5
216 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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
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 …

860 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