Subject: | File::Rename can't rename filenames containing newlines |
Date: | Wed, 14 Feb 2018 10:02:50 +1100 |
To: | bug-File-Rename [...] rt.cpan.org |
From: | Craig Sanders <cas [...] taz.net.au> |
newlines are an annoying but valid character in filenames. File::Rename
doesn't cope with them. For example:
$ touch $'foo\nbar.text'
$ find . -name '*.text' | rename 's/\.text$/.txt/'
Can't rename bar.text bar.txt: No such file or directory
rename should either have a `-0` option (e.g. for taking -print0 input
from find) or File::Rename should auto-detect that the input contains NUL
characters and set $/="\0"
BTW, a current workaround is to run rename with 'perl -0':
$ find . -name '*.text' -print0 | perl -0 /usr/bin/rename -v 's/\.text$/.txt/'
Reading filenames from file handle (GLOB(0x555555976808))
./foo
bar.text renamed as ./foo
bar.txt
Thanks,
craig