my script is not giving me any output
for file in ./*
do
if [ "$file" = *.mov ];
then
ffmpeg -i $file -an -f framemd5
fi
done
whenever I run it it just give me back my prompt immediately.
Because your test:
if [ "$file" = *.mov ];
is false.
If, for exampe, the current directory has these files:
file1.mov
file2
file3.txt
file4.mov
Then the $file variable will be set as follows through each iteration:
./file1.mov./file2./file3.txt./file4.movBut the right-hand side of the test will remain to be "file1.mov file4.mov", so each test is:
if [ "./file1.mov" = file1.mov file4.mov];if [ "./file2" = file1.mov file4.mov];if [ "./file3.txt" = file1.mov file4.mov];if [ "./file4.mov" = file1.mov file4.mov];...neither of which is ever true.
If you want to loop through all the .mov files in the current directory, use this instead:
for file in ./*.mov; do
ffmpeg -i $file -an -f framemd5
done
By the way, you should always be ready for files with spaces and other annoying characters in the name, so this would be a bit more robust:
for file in ./*.mov; do
ffmpeg -i "$file" -an -f framemd5
done
As it will put quotes around the file name.
./*.mov to "$1"/*.movAssuming you are using bash, you need to use the [[ command for pattern matching.
for file in ./*
do
if [[ "$file" = *.mov ]];
then
ffmpeg -i "$file" -an -f framemd5
fi
done
However, it's simpler to just match the .mov files in the first pattern as shown by dovetalk.