How to find .mp4 files in a specific directory and create txt file with additional text wrapped around the filenames

Solution 1:

Assuming that you are in the the directory these files exist-

file1.mp4 file2.mp4 file3.mp4 otherclip.mov

and the output that you want into a text file is named list.txt, you could redirect the output of the following into the named file-

printf "file '%s'\n" *.mp4 > list.txt

Solution 2:

Something like

cd directory/with/videofiles
for f in *.mp4; do
    echo "file '$f'" >> ./file-for-ffmpeg
done

should do.

Or

cd directory/with/videofiles
ls *.mp4 | sed -E "s|(.*)|file '\1'|" > ./file-for-ffmeg

if you look for a simple one-liner.