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.

gniourf_gniourf
  • 44,650
  • 9
  • 93
  • 104
SebS
  • 571
  • 3
  • 6
  • 16

1 Answers1

2

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

gniourf_gniourf
  • 44,650
  • 9
  • 93
  • 104
toddlermenot
  • 1,588
  • 2
  • 17
  • 33
  • I did and is working now. I realised that I left out the E from the variable as in $CMDEXE – SebS Nov 22 '14 at 21:17
  • @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 http://stackoverflow.com/questions/11065077/eval-command-in-bash-and-its-typical-uses – toddlermenot Nov 22 '14 at 21:22