• Re: [gentoo-user] Renaming files with those pesky picture type characte

    From Michael@21:1/5 to All on Tue Oct 29 15:47:27 2024
    On Tuesday 29 October 2024 15:18:40 GMT Dale wrote:
    Howdy,

    I downloaded some files. I have a few that have some weird names. Some
    have those picture type characters. Some start with a dash, "-". In
    some cases I can use wild cards to change them. Frank gave me some
    ideas on that off list, while discussing his nifty checksum tool.
    Anyway, I ran up on a few that start with a dash, "-", and I can't find
    a way around that. The mv command thinks it is me trying to include a option. It spits out something like this.


    mv: unrecognized option '---ne.avi'


    Some of the other characters I run into look like this.


    ����


    Those I can usually get around with wildcards. I have not found a way
    to get around the ones with the dash in front tho. I tried a single
    quote, double quote etc but still no worky. Also, tab completion
    doesn't help either.

    One reason I want to change these, it makes Frank's script puke on my keyboard. It reacts the same way with Franks script as it does when I
    try to use cp or mv. Why someone would name files that way is beyond me.

    What is the trick to rename these files? I've tried mv, Dolphin,
    Krusader and such. There has to be a way but I can't figure out what it
    is. Heck, I'm not even sure what to search for to find out how to do
    this.

    Thanks.

    Dale

    :-) :-)

    In a terminal running bash you can try:

    mv ./-ne.avi newname.avi

    or use a double dash to indicate end of options for the preceding command:

    mv -- -ne.avi newname.avi

    For a GUI-fied application, you can use 'kde-misc/krename'.

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCAAdFiEEXqhvaVh2ERicA8Ceseqq9sKVZxkFAmchA48ACgkQseqq9sKV ZxlFcxAAmbPyTlrmqEtTdbRYKSdw89NGh2CDdY9AI4IrD4Ry+DMOCfpIq3ZO42ET l5Nr4uYkhglhEyHWIWQJE93DubqlN/aT0ZWY6V98qaIvF94Yvz6YqA7GioupWFZQ M/o3OOO6riB/gAreHU6dixNAf+0ASTEqa4nXkAylAzOUdKBEUwgsqE4ZJdvyaRgR mRtb5/tkP7TZtxjMkfurG7K1jLZjPoVbclpNfzXpKPSWjk0v7WAdidYoLp4jeQ7j R9AChwExKvdfo7nSPpETTXjfaSK0EYwlp7qTL39WpNtS+vJuWrLT+Og5llXtPJV0 vmUt1tpiykPppGKs2N98sgC/xdvCNurXfcj62WE862nCS39lVPtWZv1BO7N031Xe RXND0pv/w0lsPyCUJjnw0OADDM3YxZesvv7k+SoQfakAneNwzVwRNWRBmEu/PiFv Jc1Dx5w6s93h8BzQcCFLLu0wKrI+HSeygUFY+OuQULgg7BtUvX1EcmlKDuBCmbgA 7QxSSKH03kQDMuINvyUJdh907d7y4qfas3W9w3WzosjXnyxwTFk2R4hkbfcWDw7g fzfH7Z27BoQMJCj/OFv6JEfzUpICSW5xox3qDYBCF/qqX8jBTzQ+d6RP7a5gn17E TVwtRxJSjjxbXmtoxufLjdfOLnlI2de9S9BJmGwzo6R78MgbLjk=
    =CO9G
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael@21:1/5 to All on Tue Oct 29 16:40:11 2024
    On Tuesday 29 October 2024 16:18:21 GMT Dale wrote:
    Michael wrote:

    In a terminal running bash you can try:

    mv ./-ne.avi newname.avi

    or use a double dash to indicate end of options for the preceding command:

    mv -- -ne.avi newname.avi

    For a GUI-fied application, you can use 'kde-misc/krename'.

    Now that is awesome. The first one works great. Haven't had the need
    to try others yet but figure they would work too. Finally, I can rename these files with weird characters. I never knew a -- meant end of
    options before. Been using Linux for a couple decades and never saw
    that info.

    I've seen it in the man pages of revdep-rebuild, perl-cleaner, et al. and have been using it for a long time. For example with revdep-rebuild I use it to pass additional options to the emerge command, which is called from within revdep-rebuild:

    revdep-rebuild -v -- -a

    This gives me a list and waits for my acknowledgement before it starts re- emerging any packages.


    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCAAdFiEEXqhvaVh2ERicA8Ceseqq9sKVZxkFAmchD+sACgkQseqq9sKV ZxkwIg//XjB5HSwkouOWk2MMRFZfFPlkTyGJktbpbACJMgAT9Ho/YnuyzRTaBpS4 H8tsoQmJNnv+dO/+a/XehYiYSteIUDS7wTIEFFjS7B+J6wUlEkwPBmeiKzkv4f28 Kbm4JWaVD7G0b3HorbuaG1w1tLaH9TfJ0U+W2oeQlxYPtnA8rNG/HPYRrMr03wqM Ll88yhpql9dHa3T0FlgdIv3KDJFM708QvppvnpTYj5Ng0CQfMHz1A120YYv4eYlv KERywa82OUJdvZSTLYUa5NfjPE4gJMGX2Af3XOmapHoUz+5ULAnn2xnufBoBrTZZ Y3K0fGbyBJSLRQjEfc921YzgoUwez17yjscMsjve7Yw70WxFdPNfvRQmnw2V5Dmx D8/2Kb1uMoOUPlHt6wHe5ooClWj6UWxkIErCuBDw7otVD7DcmUI7sLITRHfcKwuP Hn0/M/uadN3paVLQ1aeAl8D67qm+SG7K3qwlGZgwNOHLS9JPZMJaGxTkgJpWRnyA 0j0MfYj/MekxD/4mHdrWMK4iycaNO/lnqZeahbC9zSvmI1hgDulCIbkbQALUpSAj 82wRVIp32+UjqMRPRRskiv0gctdvkDG66xKJwZQ3ayn5B3y8oYRVwKxO+5EwBC9U dJoyUL0kGIcSpLCfhZ0s7ZnH5wVsHxqPRHUKLradGlpKyntCtnM=
    =qk86
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli Schwartz@21:1/5 to Dale on Wed Oct 30 04:10:01 2024
    This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------J2Bu3FYpAsMLMP9O6lffdy4A
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: quoted-printable

    On 10/29/24 2:05 PM, Dale wrote:
    I saw that but never understood what it did. I thought it was
    something that worked just with revdep-rebuild or something. So it
    is a bash thing. Interesting. That could open a can of worms.

    It's not a bash thing. It is a software thing. It is mandated by the
    POSIX standard:

    https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html

    That means, as a general rule of thumb, all Unix commands required to
    exist everywhere, *have to* support the usage of "--" in this manner.
    And since it is a sensible thing to do, most programs, even not POSIX
    programs, heed the wise advice of POSIX and support "--".


    On 10/29/24 11:18 AM, Dale wrote:
    Howdy,

    I downloaded some files. I have a few that have some weird names.
    Some have those picture type characters. Some start with a dash,
    "-". In some cases I can use wild cards to change them. Frank gave
    me some ideas on that off list, while discussing his nifty checksum
    tool. Anyway, I ran up on a few that start with a dash, "-", and I
    can't find a way around that. The mv command thinks it is me trying
    to include a option. It spits out something like this.


    mv: unrecognized option '---ne.avi'


    Some of the other characters I run into look like this.


    ����


    Those I can usually get around with wildcards. I have not found a
    way to get around the ones with the dash in front tho. I tried a
    single quote, double quote etc but still no worky. Also, tab
    completion doesn't help either.


    I feel like, in combination with the bash comment above, this speaks to
    a general misunderstanding of how quotes, dashes, wildcards, etc work.


    So I would like to clarify something here. If you try to

    $ mv ---ne.avi new-filename.avi

    and it doesn't work, and you try

    $ mv "---ne.avi" new-filename.avi


    Or more generally, if you have a filename named

    this is a weird filename.avi


    You have various options for writing a "mv" command for it in a bash
    shell, but that's not actually what the "mv" program sees.

    Example:


    $ mv "this is a weird filename.avi" better.avi

    is actually executed as an operating system array:

    {"mv", "this is a weird filename.avi", "better.avi"}


    You can also do:

    $ mv this\ is\ a\ weird\ filename.avi better.avi

    Still, bash tries to figure out how to convert it into an operating
    system array, and gets:

    {"mv", "this is a weird filename.avi", "better.avi"}

    You can even do:

    $ mv *weird*filename.avi" better.avi

    Still, bash tries to figure out how to convert it into an operating
    system array, and gets:

    {"mv", "this is a weird filename.avi", "better.avi"}

    It's always converted to that array. But,

    $ mv this is a weird filename.avi better.avi

    becomes this array:

    {"mv", "this", "is", "a", "weird", "filename.avi", "better.avi"}

    and obviously that is an entirely different command because the array is different (each part is a different filename, as far as "mv" knows.)


    Same with stuff that begins with a dash.

    $ mv "---ne.avi" new-filename.avi
    $ mv '---ne.avi' new-filename.avi
    $ mv ---ne.avi new-filename.avi
    $ mv *-ne.avi new-filename.avi
    $ mv \-\-\-ne.avi new-filename.avi


    all become

    {"mv", "---ne.avi", "new-filename.avi"}


    Which does not help you because the array values that the "mv" command
    sees are still starting with a single dash.


    From bash (and from bash tab completion) all you can do is update bash
    text lines which then get translated into arrays so you can execute the
    array as a program. Quoting and wildcards do NOT affect how "mv" works.
    All that quoting and wildcards do is affect whether space characters are interpreted as part of the filename or as the separator between
    different array items.

    The "mv" program is responsible for knowing what a dash is or does. It
    tries first to treat it as an option, and that's why "--" works --
    because it tells "mv" itself to stop treating it as an option, and to
    treat it as a filename instead.

    That is also why "./---new.avi" works. All filenames (except those
    starting with / such as /home or /usr, of course) can have an added
    directory at the beginning, and the obvious one is ./ but you could also
    use "$PWD/---new.avi" if you wanted. Since it doesn't start with a dash,
    it can't be an option.



    --
    Eli Schwartz

    --------------J2Bu3FYpAsMLMP9O6lffdy4A--

    -----BEGIN PGP SIGNATURE-----

    wnsEABYIACMWIQTnFNnmK0TPZHnXm3qEp9ErcA0vVwUCZyGieQUDAAAAAAAKCRCEp9ErcA0vV0ce AQCN1PvuOyTAdtRALrIkK6zKRYugl9mqPCL5aGjSWFXSKQD+NpkpVHdxrjdPMiwoWtjH6D1e8D5T g1hJ4OUh3PAWoAY=
    =v2Wv
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Wol@21:1/5 to Dale on Mon Nov 4 01:00:01 2024
    On 29/10/2024 15:18, Dale wrote:
    Some of the other characters I run into look like this.


    ����

    As I understand it, these are typically characters your display doesn't
    know how to display. Eg Unicode for which it doesn't have a glyph. Or
    (unlikely nowadays) 8-bit Latin characters when all you've got is 7-bit
    Ascii.

    Bear in mind as far as linux is concerned, a file name is a string of
    bytes ending in null, with a couple of forbidden characters eg "/". So
    if your shell or whatever doesn't know how to display the bytes, that's
    what it does.

    Cheers,
    Wol

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrew Lowe@21:1/5 to Dale on Fri Nov 1 11:30:01 2024
    On 10/29/24 11:18 PM, Dale wrote:
    Howdy,

    I downloaded some files.  I have a few that have some weird names.  Some have those picture type characters.  Some start with a dash, "-".  In
    [snip]

    Plenty of people have replied with good info. My 2c from when I came across this exact problem is "vidir" contained in "moreutils".

    Also, thumbs up for the tid-bit on "--" terminating the options string.

    Andrew

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jack Ostroff@21:1/5 to Andrew Lowe on Fri Nov 1 15:20:01 2024
    On 10/31/24 10:25 PM, Andrew Lowe wrote:
    On 10/29/24 11:18 PM, Dale wrote:
    Howdy,

    I downloaded some files.  I have a few that have some weird names.  Some >> have those picture type characters.  Some start with a dash, "-".  In
    [snip]

        Plenty of people have replied with good info. My 2c from when I
    came across this exact problem is "vidir" contained in "moreutils".

        Also, thumbs up for the tid-bit on "--" terminating the options string.

        Andrew

    To add another 2c, 'ls -b' should show escape sequences you should be
    able to use to type in the characters, so I'm curious what that would
    have showed.  I also still wonder what Dolphin did - Dale said it 
    failed, but not how.

    Jack

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)