Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Files with arabic names

by Anonymous Monk
on Jul 13, 2017 at 18:35 UTC ( [id://1195064]=note: print w/replies, xml ) Need Help??


in reply to Files with arabic names

What code have you tried? Is it Windows or Unix/Linux/OSX? Windows: Perl on Windows: file names with accented characters, UTF-8 and -e, Rename Windows files with Unicode chars

Replies are listed 'Best First'.
Re^2: Files with arabic names
by Anonymous Monk on Jul 13, 2017 at 18:41 UTC

    I'm looking for script in UNIX based systems. I have list of files in file. I'm able to process and delete files in English ( ASCII ) language through unlink function , but unable to delete these in other language.

    If no such solution then I can try from windows system ( mount fs on windows ).

    Any lead appreciated.
      but unable to delete these in other language

      Please see How do I post a question effectively? and show us an SSCCE with which we can reproduce the problem on our end. I'd have to guess that maybe it has something to do with the encoding of the file containing the list of files, see e.g. encguess for a way to find out how it's encoded. The following works for me, my terminal is entirely UTF-8. Note how I specify the file's encoding in the open.

      $ touch 'jdid rai dz cheb mourad 2017- No No No Madamti new album شاب مراد كالعادة يصرع'
      $ touch '✪ Lotfi Double Kanon✪ 2017 جديد ⁄ أنا'
      $ ls jdid* *Lotfi* >list.txt
      $ cat list.txt 
      jdid rai dz cheb mourad 2017- No No No Madamti new album شاب مراد كالعادة يصرع
      ✪ Lotfi Double Kanon✪ 2017 جديد ⁄ أنا
      $ encguess list.txt
      list.txt	UTF-8
      $ perl -wMstrict
      open my $fh, '<:encoding(UTF-8)', 'list.txt' or die $!;
      chomp( my @files = <$fh> );
      close $fh;
      my $count = unlink(@files);
      print "Deleted $count files\n";
      __END__
      Deleted 2 files
      $ ls
      list.txt
      $ 
      
        every file ends with an extension contains ASCII code. ex: 37.105.87.242inacheve_(無修正)(個人撮影) 援助交際白書Np.2 - 美鈴16才.avi if i keep the file path in a text file, is there a way to read the extension of the file and delete instead of reading whole file path and encoding?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found