Results 1 to 6 of 6

Thread: Problems with filename sorting order in various programs

  1. #1

    Default Problems with filename sorting order in various programs

    I am trying to prepare a set of images for display in an image viewer slideshow. I have given the files names which should be sorted in alpha-numeric order and display in the correct sequence. When I use the Unix "ls" command, their order is exactly what I want and would expect. However, I am consistently getting several names in the wrong order in software working with those names. This happens in gwenview, ritstretto, showfoto and gthumb. I have the same problem in file viewers dolphin and thunar. Even file selector boxes display the names in the wrong order. There are 84 files in the directory and most are correctly ordered except for this section in the middle of the list:
    Code:
    ...
    /home/photos/grandma/198800-28-Print.jpg
    /home/photos/grandma/198900-0015.jpg
    /home/photos/grandma/198900-0017.jpg
    /home/photos/grandma/198900-0020.jpg
    /home/photos/grandma/198900-24-Print.jpg
    /home/photos/grandma/199000-0007.jpg
    /home/photos/grandma/199000-23-Print.jpg
    /home/photos/grandma/199100-20-Print.jpg
    /home/photos/grandma/199100-27-Print.jpg
    /home/photos/grandma/200500-29-Print.jpg
    /home/photos/grandma/200600-0527-family-lake.JPG
    /home/photos/grandma/200600-IMG_0032.JPG
    /home/photos/grandma/200600-IMG_0036.JPG
    /home/photos/grandma/200600-IMG_0069.JPG
    /home/photos/grandma/201000-30-Print.jpg
    /home/photos/grandma/201000-31-Print.jpg
    /home/photos/grandma/201600-32-Print.jpg
    /home/photos/grandma/20040925-DSC00835.jpg
    /home/photos/grandma/20070428-0298.JPG
    /home/photos/grandma/20071011_0428.JPG
    /home/photos/grandma/20071013_0429.JPG
    /home/photos/grandma/20071028_0441.JPG
    /home/photos/grandma/20071226-0563.JPG
    /home/photos/grandma/20071226-gg2.JPG
    /home/photos/grandma/20071226_IMG_0546.JPG
    /home/photos/grandma/20090925-gg.jpg
    /home/photos/grandma/20090926-1615.JPG
    /home/photos/grandma/20100712-0004.JPG
    /home/photos/grandma/20110429-2898.JPG
    /home/photos/grandma/20110430-2920.JPG
    /home/photos/grandma/20111030-4044.JPG
    /home/photos/grandma/20120513-4504.JPG
    /home/photos/grandma/20120930_IMG_4702.JPG
    /home/photos/grandma/20130615-0451.JPG
    Can anyone suggest what I need to do to display the files in the wanted order?

    I am using Leap 42.1 and XFCE

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,170

    Default Re: Problems with filename sorting order in various programs

    To begin with, there is no "right" or "wrong" here, except from your personal viewpoint. It s either sorted to ASCII or to some other policy (often called "logical" by some typical end-user GUI programs).
    E.g. with the numbers 1-12:
    ASCII: 1 10 11 12 2 3 4 5 6 7 8 9
    logical 1 2 3 4 5 6 78 10 11 12
    In many lists the latter is accepted by the user as "logical" without further notice. But this "logical" sort depends on a lot of assumptions about what is logical from the application designer. It might be that an application does have a switch.

    That said, I tried to find where your list goes "wrong" (not ASCII), but failed with a headache. Thus I copied it to a file and sorted it to another file and ten used diff:
    Code:
    henk@boven:~/test/sp> diff in out
    9a10
    > /home/photos/grandma/20040925-DSC00835.jpg
    15,18d15
    < /home/photos/grandma/201000-30-Print.jpg
    < /home/photos/grandma/201000-31-Print.jpg
    < /home/photos/grandma/201600-32-Print.jpg
    < /home/photos/grandma/20040925-DSC00835.jpg
    27a25,26
    > /home/photos/grandma/201000-30-Print.jpg
    > /home/photos/grandma/201000-31-Print.jpg
    34a34
    > /home/photos/grandma/201600-32-Print.jpg
    henk@boven:~/test/sp>
    in the hope that others now see where you have your problem.

    IMHO, when you want things sorted, you must start from a common aspect to sort t on. In this case it looks as if you want sorted according to date, but there is not a normalized format for the date in your file names. That should be your first concern.

    When these JPEG pictures still have the date/time the picture is token in the internal JPEG information, the tool jhead can be off help here. I allows you to change the file name using the internal date. Thus e.g. make them all yyyymmdd-hhmmss-someting.jpeg
    Henk van Velden

  3. #3

    Default Re: Problems with filename sorting order in various programs

    Quote Originally Posted by hcvv View Post
    To begin with, there is no "right" or "wrong" here, except from your personal viewpoint. It s either sorted to ASCII or to some other policy (often called "logical" by some typical end-user GUI programs).
    E.g. with the numbers 1-12:
    ASCII: 1 10 11 12 2 3 4 5 6 7 8 9
    logical 1 2 3 4 5 6 78 10 11 12
    In many lists the latter is accepted by the user as "logical" without further notice. But this "logical" sort depends on a lot of assumptions about what is logical from the application designer. It might be that an application does have a switch.

    That said, I tried to find where your list goes "wrong" (not ASCII), but failed with a headache. Thus I copied it to a file and sorted it to another file and ten used diff:
    Code:
    henk@boven:~/test/sp> diff in out
    9a10
    > /home/photos/grandma/20040925-DSC00835.jpg
    15,18d15
    < /home/photos/grandma/201000-30-Print.jpg
    < /home/photos/grandma/201000-31-Print.jpg
    < /home/photos/grandma/201600-32-Print.jpg
    < /home/photos/grandma/20040925-DSC00835.jpg
    27a25,26
    > /home/photos/grandma/201000-30-Print.jpg
    > /home/photos/grandma/201000-31-Print.jpg
    34a34
    > /home/photos/grandma/201600-32-Print.jpg
    henk@boven:~/test/sp>
    in the hope that others now see where you have your problem.

    IMHO, when you want things sorted, you must start from a common aspect to sort t on. In this case it looks as if you want sorted according to date, but there is not a normalized format for the date in your file names. That should be your first concern.

    When these JPEG pictures still have the date/time the picture is token in the internal JPEG information, the tool jhead can be off help here. I allows you to change the file name using the internal date. Thus e.g. make them all yyyymmdd-hhmmss-someting.jpeg
    Thanks for that. I was unaware that any order other than simple ASCII or UTF-8 existed as a formal feature for ordering file names. I have had to pad numbers with zeros in front to ensure correct sorting in the past. So all I needed to do here was to add extra trailing zeros in those names where I did not have a month and day in the file name. Easily solved when I understand the problem. Thanks so much.

  4. #4

    Default Re: Problems with filename sorting order in various programs

    Thanks for the suggestion. I had no idea that file names were normally sorted other than by ASCII or UTF-8. I have often needed to pad numbers on the left with zero to ensure that names compared correctly. In my case here, I needed to ensure that there were four zeros at the end of those leading numbers where I did not have a month and date when the photo was taken. They now sort correctly. Thanks so much for the advice.

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,170

    Default Re: Problems with filename sorting order in various programs

    You are welcome.

    I would not call it a "a formal feature for ordering file names". It is just an adoption of many GUI programs to the not strict logical way GUI users seem to think. And I guess they are not "formal" but may differ from application to application.

    OTOH I am not sure that we can expect from the end-user that (s)he understands ASCII (let alone Unicode). For the uninitiated: why should 0 come before a? And why ! before all others? Of course there are such things defined as "collating sequence" dependent of the script/language used. But again, many end-users will still say: that is not what I expected.

    Those collating sequences are based on what people used before they used computers e.g. in dictionaries, etc. But even that is not hard. E.g. German uses two of them: Duden and Telefonbuch. The first being the most important German dictionary and the second being the telephone directory.

    It is not easy to adapt the strict logic of IT to human expectations.
    Last edited by hcvv; 07-May-2017 at 03:46.
    Henk van Velden

  6. #6

    Default Re: Problems with filename sorting order in various programs

    Regarding gwenview: a patch has been added recently (to kio) that makes it (and the general KDE file dialog) sort "naturally" (i.e. 10 comes after 2 instead of before).
    See https://bugzilla.opensuse.org/show_bug.cgi?id=1033668 and https://bugs.kde.org/show_bug.cgi?id=343452.
    (the patch currently is only in Tumbleweed and 42.3 though, and in the devel repo, KDE:Frameworks5, of course)

    In dolphin this is (and was) configurable already.

    That probably wouldn't change much in this case though, because of the separators ('-' and '_') used.
    Last edited by wolfi323; 07-May-2017 at 04:48.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •