I have a Java program that reads an image file (.jpg, .bmp, .png )) and creates indices on that file using a clustering algorithm. But the problem is that every time I have to explicitly give the name of that image file, which is to be indexed. What I want is a code that will automatically scan all images present in my Linux system and index them. I found it's possible by shell script but still not getting it.
Take the 2-minute tour
×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
|
You can use find, and pipe its output to your program:
and read the filenames, including paths, from stdin (assuming none of them contains a newline character). For the whole filesystem, you would start from the root dir:
A better solution, and not too hard to implement, would be, to search the files in a platform neutral manner from your program, and giving it only a starting path. Here is a good solution, you only need to apply a filter for the file types (jpg, png, bmp). |
|||
|
From what I understand, you want to execute an *.sh script through a java program which in turn loops over some files in a folder? Have you tried something like this:
This only gives a rough idea what you need to do, but you get the gist |
|||||||||
|