how to write up a batch file?


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

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

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

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

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.
Look at this code - which traverses the filess recursivelt through subdirectories:

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) {
        File[] files = folder.listFiles();
        for(int j = 0; j < files.length; j++) {
                getFiles(files[j], list);

Open in new window

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

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

Look at this trail - it has bunch of codes copying files:

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

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

From novice to tech pro — start learning today.