How can i batch rename my files with specific command by mv?
find /opt/media/rec -maxdepth 1 -type f -name '*.mp4' -mmin +1 -exec basename {} \; | awk -F_ -v OFS="_" '{sub(/\.[^.]*$/,"",$3);$3=gensub(/-([^-]*$)/,"_\\1","g",$3);gsub(/\./,"-",$3);gsub(/\./,"-",$2);;print $3,$1,$2,$4}'
I have a directory /opt/media/rec. In this directory stored recordings of live stream from WOWZA. I need to rename files to another name (for example, i have "now_360p_2014-05-19-18.12.49.996-FET_0.mp4", by the upper comand with awk file name transform to other name "2014-05-19_18-12-01_now_720p_0.mp4"). I do this script
#!/bin/bash
for f in $(find /opt/media/rec/ -maxdepth 1 -iname "*.mp4");
do
mv
awk -F_ -v OFS="_" '{sub(/\.[^.]*$/,"",$3);
$3=gensub(/-([^-]*$)/,"_\\1","g",$3);
gsub(/\./,"-",$3);
print $3,$1,$2,$4}'
done
but i have error:
[root@media rec]# sh autorename.sh
: command not found2:
'utorename.sh: line 3: syntax error near unexpected token `
'utorename.sh: line 3: `for f in $(find /opt/media/rec/ -maxdepth 1 -iname "*.mp4");