Odd characters in filename

Matthew Seaman m.seaman at infracaninophile.co.uk
Fri Jun 4 02:56:07 PDT 2004


On Fri, Jun 04, 2004 at 11:41:38AM +0200, Joachim Dagerot wrote:
> I unpacked a rar file and find myself standing with a lot of files
> with strange characters like accents etc.
> 
> When I do tab for completion the characters 'escapes' to for example
> "\264" (backward slash).
> 
> I tried to write a small rename method in java but neither the
> File.list() or by providing the filename in args[0] makes java
> understand these odd characters.
> 
> How can I rename these files in a not too manual way?

Hmmm... something like this:

    % perl -e 'for(@ARGV) { ($f = $_) =~ s/[^[:ascii:]]/_/g; rename $_, $f; }' \       filename...

which will replace all non-ascii characters with '_'.  This doesn't
take any account of possible name collisions and it will probably get
it's knickers in a twist if you use it to rename whole directory
trees, rather than just files in the current directory.

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20040604/1d319ca5/attachment.bin


More information about the freebsd-questions mailing list