OS: Raspbian
I'm currently working on a bash script that will merge all .AVI videos in the current directory, to one .AVI file. I've found the following to work perfectly for me, when run directly in the terminal:
ffmpeg -f concat -safe 0 -i <(find . -name '*.avi' -printf "file '$PWD/%p'\n") -c copy "$(date -d '-1 day' +'%F')".avi
This works perfectly, and I find a new .AVI file listed in the current directory (with a date name from yesterday).
Now, when I add this same command to my script (merge.sh), I get the following output:
/home/pi/Documents/MotionScripts/merge.sh: 11:
/home/pi/Documents/MotionScripts/merge.sh: Syntax error: "(" unexpected
This is beyond frustrating. And yes, ffmpeg command from earlier is on line 11. The script navigates to the correct directory where the multiple .avi files are stored.
Here is the entire script:
#!/bin/bash
#This script combines multiple AVI files within the current directory, into one long video
cd /media/myBook/Security/yesterday
sudo mv * /home/pi/Videos/tempconversion
cd /home/pi/Videos/tempconversion
ffmpeg -f concat -safe 0 -i <(find . -name '*.avi' -printf "file '$PWD/%p'\n") -c copy "$(date -d '-1 day' +'%F')".avi
sudo mv "$(date -d '-1 day' +'%F')".avi /media/myBook/Security/yesterday
sudo rm -f *
Why am I getting the syntax error only when the same command is being issued within an executable script?
RESOLVED! Shouldn't have used 'sh' to run the script. Make sure the script is executable (sudo chmod +x merge.sh) and run by entering the full path.