how to write up a batch file?

Hi,

I have a java app which takes one file name and check something and returns a message (pass or fail)
1) I need to write up a batch file to run on a folder contains files and subfolders.
2) also I need to copy the failed files to another folder with the same folder structure as the original

Input folder
A
A/file1
A/1/file2
A/B/file3
A/E/file4

output folder
A
A/
A/1/file2   <==if file fails the test
A/B/
A/E/

Can you help me how I need to kickstart please?
Is there an example I can take a look?
dkim18Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dkim18Author Commented:
I think I used the term incorrectly.
I want to write up a java app or a batch file to process the folder.

My java application handles one file
java CheckPdforNot filename
Then it returns a string "Not PDF" or "PDF"
If it is not pdf, I want to copy that from the input folder and put it in the output folder and need to keep same folder structure.
0
for_yanCommented:
Look at this code - which traverses the filess recursivelt through subdirectories:

http://www.java-forums.org/new-java/4123-how-do-you-recursively-traverse-through-file-folders.html

import java.io.File;
import java.util.*;
 
public class GatheringFiles {
    public static void main(String[] args) {
        File folder = new File(".");
        List<File> list = new ArrayList<File>();
        getFiles(folder, list);
        System.out.println("list.size = " + list.size());
    }
 
    private static void getFiles(File folder, List<File> list) {
        folder.setReadOnly();
        File[] files = folder.listFiles();
        for(int j = 0; j < files.length; j++) {
            list.add(files[j]);
            if(files[j].isDirectory())
                getFiles(files[j], list);
        }
    }
}

Open in new window

0
for_yanCommented:
Howevere you probably do not ned to create list of files - you ca use thre aasaem ideology - and then
check each file and then use mkdirs() method to create the path for the file which needs to be copied and coopy the file
to the new location
0
for_yanCommented:


you ca use the static method from here to do the actual copying of the files:

http://www.roseindia.net/java/beginners/CopyFile.shtml
0
for_yanCommented:


Look at this trail - it has bunch of codes copying files:
http://www.experts-exchange.com/Programming/Languages/Java/Q_27286133.html

Thosugh I don't think it goess recursively through the foldwer - for that use the code above
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.