How to list all files in the ".ts" format of folders and subfolders to be converted to ".avi"?

1

I found a shell script and modified it to meet my need and it looked like this:

#!/bin/bash
[ "$1" ] && cd "$1"

ls -1 *.TS
[ "$?" -ne 0 ] && echo 'Sem arquivos TS nesse diretório' && exit 0
for ARQUIVO in $(ls -1 *.TS)
do
ARQ_DESTINO="${ARQUIVO%%.TS}.avi"
echo "Convertendo $ARQUIVO para $ARQ_DESTINO"

ffmpeg -i "$ARQUIVO" -vcodec libxvid -b 2000k \
-acodec libmp3lame -ac 2 -ar 44100 -ab 128k "$ARQ_DESTINO"
done

I do not know how to do this script to get into the subdirectories and get every file .ts and convert it to .avi , in that case it just does it in the directory where the script is.

How can I do with this script to do this process?

    
asked by anonymous 25.10.2016 / 22:37

1 answer

4

It may be more appropriate to use find for this task:

find . -name "*.TS" | while read -r ARQUIVO; do
  ARQ_DESTINO="${ARQUIVO%%.TS}.avi"
  echo "Convertendo $ARQUIVO para $ARQ_DESTINO"
  #....   
done

The point . indicates the current directory, the search starts from it.

    
25.10.2016 / 23:14