2

I would like to call this shell script:

#!/bin/sh
exiftool -a -u -g1 -j videos/$filename > metadata/$filename1.json;

From a program in java. I try this:

    File dir = new File("videos"); 
    String[] children = dir.list(); 
    if (children == null) { 
        // Either dir does not exist or is not a directory 
        System.out.print("No existe el directorio\n");
        } else { 
            for (int i=0; i<children.length; i++) { 
                // Get filename of file or directory 
                String filename = children[i];

                //Recojo el momento exacto
                Process p = Runtime.getRuntime().exec("/home/slosada/workspace/Hola/Metadata.sh "+filename+" "+filename+"");

            }

        }

But my computer is blocked and I can't do anything. Also, there are no output files.
Maybe, the problem is in how I call the script and how I pass the parametre filename.

Any help?

Thanks in advance

1 Answer 1

1

You need retrieve the arguments within your shell script:

#!/bin/sh
filename=$1
filename1=$2
exiftool -a -u -g1 -j videos/$filename > metadata/$filename1.json
Sign up to request clarification or add additional context in comments.

1 Comment

That was the poroblem!! Thank you so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.