Reputation: 1199
I have these variables:
$reel = XF_1
$base = AA000201
$output_dir = directory
This command isn't working. It produces a file called directory/AA000201.mp4
ffmpeg -i $1 $output_dir"/$reel_$base.mp4
This command works. It produces a file called directory/XF_1_AA000201.mp4.
ffmpeg -i $1 $output_dir"/"$reel"_"$base".mp4"
But it gives this error: /Volumes/RAID/LIGHTS/RawFootage/Day01/B_Camera/XF_1/CONTENTS/CLIPS001/AA0002/AA000201.MXF: line 5: continue: only meaningful in a for',
while', or `until' loop
Note: I have shortened directory names here for simplicity.
Upvotes: 1
Views: 100
Reputation: 2657
Polbrelkey gave you the answer, but i'm still gonna add this.
Lets see why ffmpeg -i $1 $output_dir"/$reel_$base.mp4
is un-interpretable unambiguously :
Look at those three variables :
reel="A"
reel_="B" #Nothing prevents you from ending a variable with an underscore
base="C"
Now, let's interpret ffmpeg -i $1 $output_dir"/$reel_$base.mp4
:
Depending on how your decompose the string, you get either :
#ffmpeg -i $1 $output_dir"/${reel_}${base}.mp4
ffmpeg -i $1 $output_dir"/BC.mp4
#ffmpeg -i $1 $output_dir"/${reel}_${base}.mp4
ffmpeg -i $1 $output_dir"/A_C.mp4
In your case, Bash is actually interpreting the first one (actually, he looks for the longest possible variable name) and since reel_=""
is not assigned, outputs directory/AA000201.mp4
.
You don't have these kind of problems with base.mp4
since a variable name can't have a dot.
Source : Parameter Expansion on Bash-Hackers
Upvotes: 1