Saturday, December 1, 2012

Script to translate multiple filenames


The script is:

    for i in *.txt
        mv "$i" "$(echo ${i%.txt} | translate-bin -s google -f ru -t fr).txt";

You need to install this:

sudo apt-get install libtranslate0 libtranslate-bin

1. replace extension (txt, jpg, mp3 etc, in the three places where it appears)  with the one desired

2. replace in  '-f ru -t fr' (from one language to the other) with the two languages involved

3. save that in a file and make it executable

4. run script in the directory with the files (or run `./script` in terminal there) - use a different file manager if it doesn't work in  pcmanfm

(The script replaces the old old filenames irreversibly so backup first.)

No comments:

Post a Comment