Bacula-users

[Bacula-users] script to find file names with non-utf8 characters

2008-06-12 14:42:20
Subject: [Bacula-users] script to find file names with non-utf8 characters
From: Kendall Shaw <kshaw AT kendallshaw DOT com>
To: bacula-users AT lists.sourceforge DOT net
Date: Thu, 12 Jun 2008 11:46:08 -0700
In case this is of use to anyone. I used this perl script to find files
with non-utf8 characters in their names:

use Encode 'decode_utf8';

sub check_dir {
    my $dir = shift @_;
    eval { decode_utf8($dir, 1) };
    if ($@) {
        print "$dir\n";
    }
    if (opendir DIR, $dir) {
        for my $entry (readdir DIR) {
            next if $entry eq ".";
            next if $entry eq "..";
            if (-d "$dir/$entry") {
                check_dir("$dir/$entry");
            } else {
                eval { decode_utf8($entry, 1) };
                if ($@) {
                    print "$dir/$entry\n";
                }
            }
        }
    }
}

check_dir($ARGV[0]);

Kendall



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users

<Prev in Thread] Current Thread [Next in Thread>
  • [Bacula-users] script to find file names with non-utf8 characters, Kendall Shaw <=