andalou has asked for the wisdom of the Perl Monks concerning the following question:
I'm using perl 5.12.4 on windows 7.
I have files which have the word canción in their filenames and I
want
to change it to poesía. How can I do it? If I use the following
script,
canción will be converted to poesÃa and not poesía.
#!perl use utf8; my $directory = '.'; opendir (MYHANDLE , $directory) || die "Cant open directory :$!\n"; my @files = readdir MYHANDLE; closedir MYHANDLE; foreach (@files) { my $original = $_; s/canción/poesía/; rename "$directory\\$original", "$directory\\$_"; }
The filenames are of the form:
canción de la vida.txt canción de la naturaleza.txt canción 和平之歌.txt ...
Many thanks in advance,
Cesar
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: renaming filenames
by GrandFather (Saint) on Aug 15, 2012 at 05:45 UTC | |
by andalou (Novice) on Aug 16, 2012 at 04:09 UTC | |
by GrandFather (Saint) on Aug 16, 2012 at 05:21 UTC | |
by andalou (Novice) on Aug 16, 2012 at 16:44 UTC | |
by Anonymous Monk on Aug 16, 2012 at 16:50 UTC | |
| |
Re: renaming filenames
by tobyink (Canon) on Aug 15, 2012 at 05:52 UTC | |
Re: renaming filenames
by Anonymous Monk on Aug 15, 2012 at 06:44 UTC | |
by andalou (Novice) on Aug 16, 2012 at 04:13 UTC | |
by Anonymous Monk on Aug 16, 2012 at 07:07 UTC | |
by andalou (Novice) on Aug 16, 2012 at 22:05 UTC | |
by Anonymous Monk on Aug 18, 2012 at 08:12 UTC | |
Re: renaming filenames
by pvaldes (Chaplain) on Aug 16, 2012 at 09:24 UTC | |
by remiah (Hermit) on Aug 16, 2012 at 13:09 UTC | |
by andalou (Novice) on Aug 16, 2012 at 22:12 UTC | |
by remiah (Hermit) on Aug 17, 2012 at 15:29 UTC | |
by andalou (Novice) on Aug 21, 2012 at 22:44 UTC | |
| |
by pvaldes (Chaplain) on Aug 17, 2012 at 14:15 UTC |
Back to
Seekers of Perl Wisdom