Practical command to rename files using regular expressions:
perl -we '$regex = shift(@ARGV); $rep = shift(@ARGV); $rep =~ s/"/\"/g; $rep = qq("$rep"); foreach (@ARGV) { if (/$regex/) { $ren = s/$regex/$rep/geer;  print qq(Renombrando "$_"n          a "$ren"n); rename($_, $ren); }}' <patrón> <reemplazo> <ficheros...>
Brought up regarding the course of Programming Languages in Coursera, whose videos are numbered without prefix zero (“2 – 9 – Functions Formally (856).mp4”), so they are ordered incorrectly in most programs (like VLC).
To fix it in a Linux terminal, first we create an alias for readability (which you can also save permanently in your .bashrc):
alias  renamregex='perl -we '''$regex = shift(@ARGV); $rep = shift(@ARGV);  $rep =~ s/"/\"/g; $rep = qq("$rep"); foreach (@ARGV) { if (/$regex/) {  $ren = s/$regex/$rep/geer;  print qq(Renombrando "$_"n          a  "$ren"n); rename($_, $ren); }}''
Then we change to the directory where we have the videos, replacing my directory with yours of course (you can also just press F4 in Dolphin to open a terminal in it, where are you usas?):
cd "~/Documentos/Educación/Cursos en línea/Coursera UoW - Programming Languages/"
And we add an underscore to the duration (so that the name of the video matches the name of the subtitle):
renamregex '(d)(dd).mp4)' '$1_$2' *.mp4
Renombrando "2 - 9 - Functions Formally (856).mp4"
a "2 - 9 - Functions Formally (8_56).mp4"
Then rename all the files by adding a zero to all the lone digits, except the last one–we don't want to change the extension:
renamregex '(^|D)(d)(D)' '${1}0$2$3' *
Renombrando "2 - 9 - Functions Formally (8_56).mp4"
a "02 - 09 - Functions Formally (08_56).mp4"
As an extra reward for using the best OS for developers, you can install all the course programs with a single command (for Debian/Ubuntu and friends):
sudo apt-get install emacs24 smlnj sml-mode racket ruby libtcltk-ruby
Although SML mode requires a little fix (to prevent error “require: Constant symbol `:group’ specified in defvar”):
sudo perl -pi -e 's/^(defvar :.*n//' /usr/share/emacs/site-lisp/sml-mode/sml-compat.elsudo emacs -batch -f batch-byte-compile  /usr/share/emacs2*/site-lisp/sml-mode/sml-compat.el
If you want to use Emacs instead of DrRacket, install Quack y Geyser con:sudo apt-get install emacs-goodies-el
and for the last Geyser:wget http://ubuntu.wikimedia.org/ubuntu/pool/universe/g/geiser/geiser_0.4-1_all.debsudo dpkg -i geiser_0.4-1_all.debrm geiser_0.4-1_all.deb
(You are not of usas ubuntu sausy in the debian Jessie, you can just do apt-get install geiser
and add to your ~/.emacs:
;; Improved scheme-mode for Racket
(require 'geiser-install)
(require 'quack)
(quack-install)
If you are on Windows, you'll have to install Perl yourself and run something like:
cd "$HOMEMis DocumentosEducaciónCursos en líneaCoursera UoW - Programming Languages"
perl -we '$regex = shift(@ARGV); $rep = shift(@ARGV); $rep =~  s/"/\"/g; $rep = qq("$rep"); foreach (@ARGV) { if (/$regex/) { $ren =  s/$regex/$rep/geer;  print qq(Renombrando "$_"n          a "$ren"n);  rename($_, $ren); }}' '(d)(dd).mp4)' '$1_$2' *.mp4
perl -we '$regex = shift(@ARGV); $rep = shift(@ARGV); $rep =~  s/"/\"/g; $rep = qq("$rep"); foreach (@ARGV) { if (/$regex/) { $ren =  s/$regex/$rep/geer;  print qq(Renombrando "$_"n          a "$ren"n);  rename($_, $ren); }}' '(^|D)(d)(D)' '${1}0$2$3' *.*
But I haven't tried it.
