I have a directory structure of the form:
base_directory
/ level_one_a
, level_one_b
, level_one_c
/
then within all those directories in level_one_x
are a multitude of subsequent directories, i.e.
/ level_one_a_1
,level_one_a_2
,level_one_a_3
...
and so on for level_one_b
& level_one_c
then inside of level_one_a_1
we have more still, i.e. level_one_a_1_I
,level_one_a_1_II
,level_one_a_1_III
,level_one_a_1_IV
...
Then finally inside of level_one_a_1_IV
, and all those on the same level, are the files I want to operate on.
I guess a shorter way to say that would be start
/one
/two
/three
/*files*
There are many many files and I want to process them all with a simple java program I wrote:
try
{
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null)
{
sb.append(line);
sb.append(System.lineSeparator());
line = br.readLine();
}
String everything = sb.toString();
Document doc = Jsoup.parse(everything);
String link = doc.select("block.full_text").text();
System.out.println(link);
}
finally
{
br.close();
}
it uses jsoup
I'd like to construct this script such that the program can navigate this directory structure autonomously and grab each file then process it with that script, using buffered reader and file reader I guess, how can I facilitate that? I tried implementing this solution but I couldn't get it to work.
Ideally I want to output each file it processes with a unique name, i.e. is the file is named 00001.txt
it might save it as 00001_output.txt
but, that's a horse of a different colour