Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Rename Windows files with Unicode chars

by beech (Parson)
on Aug 27, 2016 at 03:44 UTC ( [id://1170566]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Rename Windows files with Unicode chars
in thread Rename Windows files with Unicode chars

Hi,

Did you forget about  sub listDir { ? How does listDir cheat at reading unicode filenames?

:)

Replies are listed 'Best First'.
Re^4: Rename Windows files with Unicode chars
by mnooning (Beadle) on Aug 27, 2016 at 20:23 UTC

    I needed to have the file name as read by listDir to be what is used during the renaming. To test if the concept worked I stripped the directory of all but your script. I then created two globals, $global_file_name and $new_name. Your code created I-unicode heart-Perl. When listDir read in the file name I saved it in $global_file_name. Just prior to the rename I saved $global_file_name into $new_name. Just before the rename line I did


    $new_name =~ s![^:ascii:]!!ig;

    I then changed the rename line to

    rename $global_file_name, $new_name;

    It worked. I now know I can use this concept to strip out the unicode from a large number of files. Thank you very much for your help

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1170566]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-25 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found