How to recover these files when their filenames are changed to ” #U4e09#U661f#U4ee5#U..”?

My WordPress site is recently moved, and later I found the image filenames are changed to this kind of filename:

 #U4e09#U661f#U4ee5#U..

They are used to be filename in Chinese. Somehow they are changed to this kind of filename and I don’t really know the reason (besides, I don’t have the old files because I changed server and old files are deleted)

Read More

Now these images cannot be loaded in my posts. Is there any method to make it work?

Related posts

Leave a Reply

1 comment

  1. This Perl script might work, but only if your file system uses UTF-8 encoding for file names. Give it a try anyway:

    #!/usr/bin/perl
    # 
    # Rewrite UTF-16 codes in file names
    # Usage: fixutf.pl <directory>
    # (Defaults to current directory if omitted)
    # 
    
    use strict;
    use warnings;
    my $oldname;
    my $newname;
    my $directory = '.';
    
    binmode(STDOUT,':raw:encoding(UTF-8)');
    if ($ARGV[0]) {
       $directory = $ARGV[0];
    }
    opendir (DIR,$directory) or die $!;
    print "Scanning directory '$directory/' ...n";
    
    while ($oldname = readdir(DIR)) {
       if ($oldname =~ /#U([0-9a-f]{4})/) {
          $newname = $oldname;
          $newname =~ s/#U([0-9a-f]{4})/pack('U',hex($1))/seg;
          rename $oldname,$newname;
          print "  Renamed $oldname to $newnamen";
       }
    }
    
    print "Finishedn";
    

    Save this as “fixutf.pl”, change its permissions to 0755, and then either run it from inside the directory that contains all your files, or pass the path to this directory as a command line argument. Please back your files up first, and be aware that the renaming process will overwrite any files of the same name if they exist in the same directory.