I have this cute little console app called renamer, where i give a string (pattern) as fisrt argument and another string as secong argument, then the app replace all file names matches with the new string. I use it to rename music files.
I'll put it with my spanish comments.
# Open the current dir opendir (INPUT, "."); # Asigna el contenido del HANDLE # a un arreglo @files = readdir INPUT; # Itera sobre los archivos foreach $item (@files) { # Verifica la coincidencia # de la regexp de busqueda # en el archivo iterado if ($item =~ m/$ARGV[0]/) { # Respalda el archivo original $image = $item; # Reemplaza la coincidencia # con le string del segundo # parametro $item =~ s/$ARGV[0]/$ARGV[1]/g; # Renombra el archivo rename($image, $item) or warn "Couldn't rename $file to $item: $!\n"; } }
And does't work with patters (string) with special characters.
Is there a function that translate a string in his pattern equivalence?
Thanks
In reply to Convert a string in his pattern equivalence by ccdoub
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |