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?
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.