1

I would like to execute the following from a bash script

exiftool -r -v5 -P -ext mov -ext avi -ext mp4 -ext 3gp "-Directory<MediaCreateDate" -d "/media/data/Home Movies/testdestdir/%Y/%b/" "/media/data/Home Movies/testsrcdir/"

I have built this by concatenating strings into a $CMDEXEC when echoing the variable it looks fine but I cannot execute it from bash script. I tried various combinations without luck.

`$CMDEXEC` >> $LOGFILE

$($CMDEXEC) >> $LOGFILE

etc.

2
  • Don't put your commands into variables! See BashFAQ/050. Commented Nov 22, 2014 at 21:08
  • Great link @gniourf_gniourf I will improve my script when time allows. Commented Nov 22, 2014 at 21:32

1 Answer 1

2

Did you try eval "$CMDEXEC" >> "$LOGFILE" ?

Sign up to request clarification or add additional context in comments.

2 Comments

I did and is working now. I realised that I left out the E from the variable as in $CMDEXE
@SebS Good to know. But as gniourf_gniourf linked in his comment, it is considered a poor practice to put commands inside variables. So please avoid unless you have a good reason to do otherwise. As for `` not working, eval causes the shell interpreter to interpret again after variable expansion whereas `` does not. See stackoverflow.com/questions/11065077/…

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.