1

I have a great script that I use to convert encoding in srt.files. I also created an alias for that script so I can enter the directory where I want to run the script and use my alias konvert.

However, I have now the the following scenario: more then 20 directories with srt.files inside. What should I do in order to point my script to all those directories with just one command?

Luckily all these directories are together inside one main directory, so I believe there should be an easy way to do this.

Content of the script

#!/bin/bash for file in *.srt; do iconv -f CP1250 -t UTF-8 -o "$file".utf "$file" && mv "$file".utf "$file"; done 
Zanna
  • 72,312

1 Answers1

3

Easy enough to accomplish without your script by using the following command line (using the application recode rather than straight iconv) which should be run from the root directory of your srt files:

find . -name '*.srt' -type f -exec bash -c 'recode -v CP1250..UTF-8 "$0"' {} \;

The command line searches recursively for all srt files and when each is found recode works on each file to change character encoding from CP1250 to UTF-8. With recode the encoding alteration does not require the clumsy filename shifting required by iconv...

How cool is the command line :)

andrew.46
  • 39,359