#!/usr/bin/env fish


mkdir transcoded
mkdir source
for vid in *.MP4
    touch $vid.txt
    echo $vid >>$vid.txt
    set newvid (sed "s/\.mp4//g" $vid.txt)
    echo $newvid
    ffmpeg -i $vid -c:v dnxhd -profile:v 3 -qscale:v 20 -c:a pcm_s16be $newvid.mov
    mv $newvid.mov ./transcoded/$newvid.mov
    mv $vid source/$vid
    rm $vid.txt
    echo \n finished transcoding new file is in transcoded/$newvid.mov
end

for vid in *.MOV
    touch $vid.txt
    echo $vid >>$vid.txt
    set newvid (sed "s/\.mp4//g" $vid.txt)
    echo $newvid
    ffmpeg -i $vid -c:v dnxhd -profile:v 3 -qscale:v 4 -c:a pcm_s16be $newvid.mov
    mv $newvid.mov ./transcoded/$newvid.mov
    mv $vid source/$vid
    rm $vid.txt
    echo \n finished transcoding new file is in transcoded/$newvid.mov
end

for vid in *.mp4
    touch $vid.txt
    echo $vid >>$vid.txt
    set newvid (sed "s/\.mp4//g" $vid.txt)
    echo $newvid
    ffmpeg -i $vid -c:v dnxhd -profile:v 3 -qscale:v 4 -c:a pcm_s16be $newvid.mov
    mv $newvid.mov ./transcoded/$newvid.mov
    mv $vid source/$vid
    rm $vid.txt
    echo \n finished transcoding new file is in transcoded/$newvid.mov
end

for vid in *.mov
    touch $vid.txt
    echo $vid >>$vid.txt
    set newvid (sed "s/\.mp4//g" $vid.txt)
    echo $newvid
    ffmpeg -i $vid -c:v dnxhd -profile:v 3 -qscale:v 4 -c:a pcm_s16be $newvid.mov
    mv $newvid.mov ./transcoded/$newvid.mov
    mv $vid source/$vid
    rm $vid.txt
    echo \n finished transcoding new file is in transcoded/$newvid.mov
end

for vid in *.mkv
    touch $vid.txt
    echo $vid >>$vid.txt
    set newvid (sed "s/\.mp4//g" $vid.txt)
    echo $newvid
    ffmpeg -i $vid -c:v dnxhd -profile:v 3 -qscale:v 4 -c:a pcm_s16be $newvid.mov
    mv $newvid.mov ./transcoded/$newvid.mov
    mv $vid source/$vid
    rm $vid.txt
    echo \n finished transcoding new file is in transcoded/$newvid.mov
end
