Rename files and directories with French charactersbulk rename (or correctly display) files with special...

How would armour (and combat) change if the fighter didn't need to actually wear it?

Did Pope Urban II issue the papal bull "terra nullius" in 1095?

How much can I judge a company based on a phone screening?

Why are electric shavers specifically permitted under FAR §91.21

When did Bilbo and Frodo learn that Gandalf was a Maia?

What is the opposite of "hunger level"?

What's a good pattern to calculate a variable only when it is used the first time?

How to prevent criminal gangs from making/buying guns?

Is the Microsoft recommendation to use C# properties applicable to game development?

How can I communicate my issues with a potential date's pushy behavior?

Adding things to bunches of things vs multiplication

Why do my bicycle brakes get worse and feel more 'squishy" over time?

Cusp forms have an orthonormal basis of eigenfunctions for all Hecke operators

Why do so many people play out of turn on the last lead?

How to use Palatino font for text and what about maths?

What should I do if actually I found a serious flaw in someone's PhD thesis and an article derived from that PhD thesis?

What would cause a nuclear power plant to break down after 2000 years, but not sooner?

Help, I cannot decide when to start the story

Do I need to start off my book by describing the character's "normal world"?

Why does Japan use the same type of AC power outlet as the US?

Weird resistor with dots around it on the schematic

Did Michelle Obama have a staff of 23; and Melania have a staff of 4?

How to gracefully leave a company you helped start?

What are the advantages of this gold finger shape?



Rename files and directories with French characters


bulk rename (or correctly display) files with special charactersRename All Files with a Certain NameHow to rename files with sed and csvStrip Filenames and RenameHow to rename all files with special characters and spaces in a directory?Rename hundreds of filesRename files to change punctuation and numberingUsing rename to rename files and directoriesHow to rename filenames with accents on macOS?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







4















I use the following command on Ubuntu with rename (installed with sudo apt-get rename) to rename all files which have the given characters in regex:



find . -execdir rename 's/[^A-Za-z0-9_.@+,#!?:&%~()[]/ -]/?/g' * {} ;


This is working very well and all other characters are changed to ?. Now I want to include French characters like àèìòù and so on. So I added À-ÿ to my regex:



find . -execdir rename 's/[^A-Za-zÀ-ÿ0-9_.@+,#!?:&%~()[]/ -]/?/g' * {} ;


But somehow the files are not getting renamed and they seem to be corrupted after running this command with À-ÿ because I can't delete them anymore.



What is the right way to include them in the rename regex?










share|improve this question









New contributor



Mango D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • What variant of rename are you using (even among the perl ones, there are many)? What's the output of locale charmap?

    – Stéphane Chazelas
    yesterday











  • By French character, do you mean any letter from the Latin script with any number of diacritics, or only those that are typically used in the French languages (for instance, no á), or would any alphabetic character (in any script, not only latin) do?

    – Stéphane Chazelas
    yesterday











  • @StéphaneChazelas I updated my question. How can I check with variant I am using? Is there a specific one for Ubuntu?

    – Mango D
    yesterday






  • 1





    @StéphaneChazelas I think I can use any not only latin letters. The reason is that I want to prepare those files for a PHP Script which handles them and can't read specific special chars like line breaks, symbols or stuff like that. I want to exclude all of them.

    – Mango D
    yesterday






  • 2





    I believe the problem is that these characters are encoded in a Unicode encoding (most likely, UTF-8) and the rename command expects unibyte characters.

    – Ned64
    yesterday


















4















I use the following command on Ubuntu with rename (installed with sudo apt-get rename) to rename all files which have the given characters in regex:



find . -execdir rename 's/[^A-Za-z0-9_.@+,#!?:&%~()[]/ -]/?/g' * {} ;


This is working very well and all other characters are changed to ?. Now I want to include French characters like àèìòù and so on. So I added À-ÿ to my regex:



find . -execdir rename 's/[^A-Za-zÀ-ÿ0-9_.@+,#!?:&%~()[]/ -]/?/g' * {} ;


But somehow the files are not getting renamed and they seem to be corrupted after running this command with À-ÿ because I can't delete them anymore.



What is the right way to include them in the rename regex?










share|improve this question









New contributor



Mango D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • What variant of rename are you using (even among the perl ones, there are many)? What's the output of locale charmap?

    – Stéphane Chazelas
    yesterday











  • By French character, do you mean any letter from the Latin script with any number of diacritics, or only those that are typically used in the French languages (for instance, no á), or would any alphabetic character (in any script, not only latin) do?

    – Stéphane Chazelas
    yesterday











  • @StéphaneChazelas I updated my question. How can I check with variant I am using? Is there a specific one for Ubuntu?

    – Mango D
    yesterday






  • 1





    @StéphaneChazelas I think I can use any not only latin letters. The reason is that I want to prepare those files for a PHP Script which handles them and can't read specific special chars like line breaks, symbols or stuff like that. I want to exclude all of them.

    – Mango D
    yesterday






  • 2





    I believe the problem is that these characters are encoded in a Unicode encoding (most likely, UTF-8) and the rename command expects unibyte characters.

    – Ned64
    yesterday














4












4








4








I use the following command on Ubuntu with rename (installed with sudo apt-get rename) to rename all files which have the given characters in regex:



find . -execdir rename 's/[^A-Za-z0-9_.@+,#!?:&%~()[]/ -]/?/g' * {} ;


This is working very well and all other characters are changed to ?. Now I want to include French characters like àèìòù and so on. So I added À-ÿ to my regex:



find . -execdir rename 's/[^A-Za-zÀ-ÿ0-9_.@+,#!?:&%~()[]/ -]/?/g' * {} ;


But somehow the files are not getting renamed and they seem to be corrupted after running this command with À-ÿ because I can't delete them anymore.



What is the right way to include them in the rename regex?










share|improve this question









New contributor



Mango D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I use the following command on Ubuntu with rename (installed with sudo apt-get rename) to rename all files which have the given characters in regex:



find . -execdir rename 's/[^A-Za-z0-9_.@+,#!?:&%~()[]/ -]/?/g' * {} ;


This is working very well and all other characters are changed to ?. Now I want to include French characters like àèìòù and so on. So I added À-ÿ to my regex:



find . -execdir rename 's/[^A-Za-zÀ-ÿ0-9_.@+,#!?:&%~()[]/ -]/?/g' * {} ;


But somehow the files are not getting renamed and they seem to be corrupted after running this command with À-ÿ because I can't delete them anymore.



What is the right way to include them in the rename regex?







command-line regular-expression rename






share|improve this question









New contributor



Mango D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



Mango D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited yesterday









Stéphane Chazelas

330k58 gold badges641 silver badges1008 bronze badges




330k58 gold badges641 silver badges1008 bronze badges






New contributor



Mango D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked yesterday









Mango DMango D

234 bronze badges




234 bronze badges




New contributor



Mango D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Mango D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • What variant of rename are you using (even among the perl ones, there are many)? What's the output of locale charmap?

    – Stéphane Chazelas
    yesterday











  • By French character, do you mean any letter from the Latin script with any number of diacritics, or only those that are typically used in the French languages (for instance, no á), or would any alphabetic character (in any script, not only latin) do?

    – Stéphane Chazelas
    yesterday











  • @StéphaneChazelas I updated my question. How can I check with variant I am using? Is there a specific one for Ubuntu?

    – Mango D
    yesterday






  • 1





    @StéphaneChazelas I think I can use any not only latin letters. The reason is that I want to prepare those files for a PHP Script which handles them and can't read specific special chars like line breaks, symbols or stuff like that. I want to exclude all of them.

    – Mango D
    yesterday






  • 2





    I believe the problem is that these characters are encoded in a Unicode encoding (most likely, UTF-8) and the rename command expects unibyte characters.

    – Ned64
    yesterday



















  • What variant of rename are you using (even among the perl ones, there are many)? What's the output of locale charmap?

    – Stéphane Chazelas
    yesterday











  • By French character, do you mean any letter from the Latin script with any number of diacritics, or only those that are typically used in the French languages (for instance, no á), or would any alphabetic character (in any script, not only latin) do?

    – Stéphane Chazelas
    yesterday











  • @StéphaneChazelas I updated my question. How can I check with variant I am using? Is there a specific one for Ubuntu?

    – Mango D
    yesterday






  • 1





    @StéphaneChazelas I think I can use any not only latin letters. The reason is that I want to prepare those files for a PHP Script which handles them and can't read specific special chars like line breaks, symbols or stuff like that. I want to exclude all of them.

    – Mango D
    yesterday






  • 2





    I believe the problem is that these characters are encoded in a Unicode encoding (most likely, UTF-8) and the rename command expects unibyte characters.

    – Ned64
    yesterday

















What variant of rename are you using (even among the perl ones, there are many)? What's the output of locale charmap?

– Stéphane Chazelas
yesterday





What variant of rename are you using (even among the perl ones, there are many)? What's the output of locale charmap?

– Stéphane Chazelas
yesterday













By French character, do you mean any letter from the Latin script with any number of diacritics, or only those that are typically used in the French languages (for instance, no á), or would any alphabetic character (in any script, not only latin) do?

– Stéphane Chazelas
yesterday





By French character, do you mean any letter from the Latin script with any number of diacritics, or only those that are typically used in the French languages (for instance, no á), or would any alphabetic character (in any script, not only latin) do?

– Stéphane Chazelas
yesterday













@StéphaneChazelas I updated my question. How can I check with variant I am using? Is there a specific one for Ubuntu?

– Mango D
yesterday





@StéphaneChazelas I updated my question. How can I check with variant I am using? Is there a specific one for Ubuntu?

– Mango D
yesterday




1




1





@StéphaneChazelas I think I can use any not only latin letters. The reason is that I want to prepare those files for a PHP Script which handles them and can't read specific special chars like line breaks, symbols or stuff like that. I want to exclude all of them.

– Mango D
yesterday





@StéphaneChazelas I think I can use any not only latin letters. The reason is that I want to prepare those files for a PHP Script which handles them and can't read specific special chars like line breaks, symbols or stuff like that. I want to exclude all of them.

– Mango D
yesterday




2




2





I believe the problem is that these characters are encoded in a Unicode encoding (most likely, UTF-8) and the rename command expects unibyte characters.

– Ned64
yesterday





I believe the problem is that these characters are encoded in a Unicode encoding (most likely, UTF-8) and the rename command expects unibyte characters.

– Ned64
yesterday










1 Answer
1






active

oldest

votes


















4














Assuming those file names are encoded in UTF-8, use:



find . -depth -execdir rename -n '
utf8::decode$_ or die "cannot decode $_n";
s{[^w.@+,#!?:&%~()[]/ -]}{?}gs;
utf8::encode$_;
' {} +


(remove the -n when happy).



Beware that some BSD implementations of find do not prefix the file names with ./ with -execdir so that command could fail if there are file names that start with -. With your variant of rename, you should be able to work around it by changing rename -n to rename -n -- (that doesn't work will all other perl rename variants).



In modern versions of perl, w (for word character) is any alphanumeric (in any alphabetic script, not just Latin), or underscore character plus other connector punctuation chararcters plus Unicode marks (so for instance, includes the combining acute accent character that follows e in the decomposed form of é).



If you wanted to be more restrictive, instead of w, you could use p{latin}p{mark}0-9_ to only include letters in the Latin script (and not Cyrillic, Greek...), the combining diacritics (though not limited to those typically used with Latin letters), and only the Hindu–Arabic decimal digits (and not other kinds of digits) and underscore (and not other connector punctuation characters).



If you don't use utf8::decode, perl will assume the characters are encoded in the iso8859-1 unibyte character set (for instance where 0xc3 0xa9 (the UTF-8 encoding of the pre-composed form of é) is à ©).



Alternatively, you can use zsh (which will decode characters as per the locale's encoding (see the output of locale charmap)):



autoload zmv # best in ~/.zshrc
zmv -n '(**/)(*)(#qD)' '$1${2//[^][:alnum:]_.@+,#!?:&%~()[/ -]/?}'


Each byte from any sequence of bytes that don't form valid characters in your locale will also be turned into a ? (where rename above would die with a cannot decode error).



Its [[:alnum:]] uses your locale's alnum category so is unlikely to include other Unicode connector punctuation or marks characters.



In both perl and zsh (but often not in other tools), ranges like [a-zÀ-ÿ] are based on the codepoint of the characters. For instance azÀÿ are u0061u007Au00C0u00FF so, that range would match the abcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ characters in that range of code points (which includes non-alphabetic characters and not all characters in the Latin script or used in the French language like œ). In perl, you'd also need to add a use utf8 to be able to use the UTF-8 encoding of À and ÿ in the perl code.






share|improve this answer






























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Mango D is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535546%2frename-files-and-directories-with-french-characters%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    Assuming those file names are encoded in UTF-8, use:



    find . -depth -execdir rename -n '
    utf8::decode$_ or die "cannot decode $_n";
    s{[^w.@+,#!?:&%~()[]/ -]}{?}gs;
    utf8::encode$_;
    ' {} +


    (remove the -n when happy).



    Beware that some BSD implementations of find do not prefix the file names with ./ with -execdir so that command could fail if there are file names that start with -. With your variant of rename, you should be able to work around it by changing rename -n to rename -n -- (that doesn't work will all other perl rename variants).



    In modern versions of perl, w (for word character) is any alphanumeric (in any alphabetic script, not just Latin), or underscore character plus other connector punctuation chararcters plus Unicode marks (so for instance, includes the combining acute accent character that follows e in the decomposed form of é).



    If you wanted to be more restrictive, instead of w, you could use p{latin}p{mark}0-9_ to only include letters in the Latin script (and not Cyrillic, Greek...), the combining diacritics (though not limited to those typically used with Latin letters), and only the Hindu–Arabic decimal digits (and not other kinds of digits) and underscore (and not other connector punctuation characters).



    If you don't use utf8::decode, perl will assume the characters are encoded in the iso8859-1 unibyte character set (for instance where 0xc3 0xa9 (the UTF-8 encoding of the pre-composed form of é) is à ©).



    Alternatively, you can use zsh (which will decode characters as per the locale's encoding (see the output of locale charmap)):



    autoload zmv # best in ~/.zshrc
    zmv -n '(**/)(*)(#qD)' '$1${2//[^][:alnum:]_.@+,#!?:&%~()[/ -]/?}'


    Each byte from any sequence of bytes that don't form valid characters in your locale will also be turned into a ? (where rename above would die with a cannot decode error).



    Its [[:alnum:]] uses your locale's alnum category so is unlikely to include other Unicode connector punctuation or marks characters.



    In both perl and zsh (but often not in other tools), ranges like [a-zÀ-ÿ] are based on the codepoint of the characters. For instance azÀÿ are u0061u007Au00C0u00FF so, that range would match the abcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ characters in that range of code points (which includes non-alphabetic characters and not all characters in the Latin script or used in the French language like œ). In perl, you'd also need to add a use utf8 to be able to use the UTF-8 encoding of À and ÿ in the perl code.






    share|improve this answer
































      4














      Assuming those file names are encoded in UTF-8, use:



      find . -depth -execdir rename -n '
      utf8::decode$_ or die "cannot decode $_n";
      s{[^w.@+,#!?:&%~()[]/ -]}{?}gs;
      utf8::encode$_;
      ' {} +


      (remove the -n when happy).



      Beware that some BSD implementations of find do not prefix the file names with ./ with -execdir so that command could fail if there are file names that start with -. With your variant of rename, you should be able to work around it by changing rename -n to rename -n -- (that doesn't work will all other perl rename variants).



      In modern versions of perl, w (for word character) is any alphanumeric (in any alphabetic script, not just Latin), or underscore character plus other connector punctuation chararcters plus Unicode marks (so for instance, includes the combining acute accent character that follows e in the decomposed form of é).



      If you wanted to be more restrictive, instead of w, you could use p{latin}p{mark}0-9_ to only include letters in the Latin script (and not Cyrillic, Greek...), the combining diacritics (though not limited to those typically used with Latin letters), and only the Hindu–Arabic decimal digits (and not other kinds of digits) and underscore (and not other connector punctuation characters).



      If you don't use utf8::decode, perl will assume the characters are encoded in the iso8859-1 unibyte character set (for instance where 0xc3 0xa9 (the UTF-8 encoding of the pre-composed form of é) is à ©).



      Alternatively, you can use zsh (which will decode characters as per the locale's encoding (see the output of locale charmap)):



      autoload zmv # best in ~/.zshrc
      zmv -n '(**/)(*)(#qD)' '$1${2//[^][:alnum:]_.@+,#!?:&%~()[/ -]/?}'


      Each byte from any sequence of bytes that don't form valid characters in your locale will also be turned into a ? (where rename above would die with a cannot decode error).



      Its [[:alnum:]] uses your locale's alnum category so is unlikely to include other Unicode connector punctuation or marks characters.



      In both perl and zsh (but often not in other tools), ranges like [a-zÀ-ÿ] are based on the codepoint of the characters. For instance azÀÿ are u0061u007Au00C0u00FF so, that range would match the abcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ characters in that range of code points (which includes non-alphabetic characters and not all characters in the Latin script or used in the French language like œ). In perl, you'd also need to add a use utf8 to be able to use the UTF-8 encoding of À and ÿ in the perl code.






      share|improve this answer






























        4












        4








        4







        Assuming those file names are encoded in UTF-8, use:



        find . -depth -execdir rename -n '
        utf8::decode$_ or die "cannot decode $_n";
        s{[^w.@+,#!?:&%~()[]/ -]}{?}gs;
        utf8::encode$_;
        ' {} +


        (remove the -n when happy).



        Beware that some BSD implementations of find do not prefix the file names with ./ with -execdir so that command could fail if there are file names that start with -. With your variant of rename, you should be able to work around it by changing rename -n to rename -n -- (that doesn't work will all other perl rename variants).



        In modern versions of perl, w (for word character) is any alphanumeric (in any alphabetic script, not just Latin), or underscore character plus other connector punctuation chararcters plus Unicode marks (so for instance, includes the combining acute accent character that follows e in the decomposed form of é).



        If you wanted to be more restrictive, instead of w, you could use p{latin}p{mark}0-9_ to only include letters in the Latin script (and not Cyrillic, Greek...), the combining diacritics (though not limited to those typically used with Latin letters), and only the Hindu–Arabic decimal digits (and not other kinds of digits) and underscore (and not other connector punctuation characters).



        If you don't use utf8::decode, perl will assume the characters are encoded in the iso8859-1 unibyte character set (for instance where 0xc3 0xa9 (the UTF-8 encoding of the pre-composed form of é) is à ©).



        Alternatively, you can use zsh (which will decode characters as per the locale's encoding (see the output of locale charmap)):



        autoload zmv # best in ~/.zshrc
        zmv -n '(**/)(*)(#qD)' '$1${2//[^][:alnum:]_.@+,#!?:&%~()[/ -]/?}'


        Each byte from any sequence of bytes that don't form valid characters in your locale will also be turned into a ? (where rename above would die with a cannot decode error).



        Its [[:alnum:]] uses your locale's alnum category so is unlikely to include other Unicode connector punctuation or marks characters.



        In both perl and zsh (but often not in other tools), ranges like [a-zÀ-ÿ] are based on the codepoint of the characters. For instance azÀÿ are u0061u007Au00C0u00FF so, that range would match the abcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ characters in that range of code points (which includes non-alphabetic characters and not all characters in the Latin script or used in the French language like œ). In perl, you'd also need to add a use utf8 to be able to use the UTF-8 encoding of À and ÿ in the perl code.






        share|improve this answer















        Assuming those file names are encoded in UTF-8, use:



        find . -depth -execdir rename -n '
        utf8::decode$_ or die "cannot decode $_n";
        s{[^w.@+,#!?:&%~()[]/ -]}{?}gs;
        utf8::encode$_;
        ' {} +


        (remove the -n when happy).



        Beware that some BSD implementations of find do not prefix the file names with ./ with -execdir so that command could fail if there are file names that start with -. With your variant of rename, you should be able to work around it by changing rename -n to rename -n -- (that doesn't work will all other perl rename variants).



        In modern versions of perl, w (for word character) is any alphanumeric (in any alphabetic script, not just Latin), or underscore character plus other connector punctuation chararcters plus Unicode marks (so for instance, includes the combining acute accent character that follows e in the decomposed form of é).



        If you wanted to be more restrictive, instead of w, you could use p{latin}p{mark}0-9_ to only include letters in the Latin script (and not Cyrillic, Greek...), the combining diacritics (though not limited to those typically used with Latin letters), and only the Hindu–Arabic decimal digits (and not other kinds of digits) and underscore (and not other connector punctuation characters).



        If you don't use utf8::decode, perl will assume the characters are encoded in the iso8859-1 unibyte character set (for instance where 0xc3 0xa9 (the UTF-8 encoding of the pre-composed form of é) is à ©).



        Alternatively, you can use zsh (which will decode characters as per the locale's encoding (see the output of locale charmap)):



        autoload zmv # best in ~/.zshrc
        zmv -n '(**/)(*)(#qD)' '$1${2//[^][:alnum:]_.@+,#!?:&%~()[/ -]/?}'


        Each byte from any sequence of bytes that don't form valid characters in your locale will also be turned into a ? (where rename above would die with a cannot decode error).



        Its [[:alnum:]] uses your locale's alnum category so is unlikely to include other Unicode connector punctuation or marks characters.



        In both perl and zsh (but often not in other tools), ranges like [a-zÀ-ÿ] are based on the codepoint of the characters. For instance azÀÿ are u0061u007Au00C0u00FF so, that range would match the abcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ characters in that range of code points (which includes non-alphabetic characters and not all characters in the Latin script or used in the French language like œ). In perl, you'd also need to add a use utf8 to be able to use the UTF-8 encoding of À and ÿ in the perl code.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited yesterday

























        answered yesterday









        Stéphane ChazelasStéphane Chazelas

        330k58 gold badges641 silver badges1008 bronze badges




        330k58 gold badges641 silver badges1008 bronze badges

























            Mango D is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Mango D is a new contributor. Be nice, and check out our Code of Conduct.













            Mango D is a new contributor. Be nice, and check out our Code of Conduct.












            Mango D is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535546%2frename-files-and-directories-with-french-characters%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...