Sort jpg according to creation date and convert to single pdf












3















On a Mac, how can I sort about 2400 jpg according to their creation date (i. e. stat -f %SB) via terminal and convert them in that order into one pdf?



What if one jpg has been created today at 11:10 pm and a second one shortly after within the same minute at 11:10 pm? Are there seconds in the creation date, which can be taken into account?










share|improve this question

























  • You can do this easily with zsh (e.g. custom sorting). I don't have access to OSX so cannot post an answer but this should be piece of cake...

    – don_crissti
    Aug 5 '17 at 9:43
















3















On a Mac, how can I sort about 2400 jpg according to their creation date (i. e. stat -f %SB) via terminal and convert them in that order into one pdf?



What if one jpg has been created today at 11:10 pm and a second one shortly after within the same minute at 11:10 pm? Are there seconds in the creation date, which can be taken into account?










share|improve this question

























  • You can do this easily with zsh (e.g. custom sorting). I don't have access to OSX so cannot post an answer but this should be piece of cake...

    – don_crissti
    Aug 5 '17 at 9:43














3












3








3








On a Mac, how can I sort about 2400 jpg according to their creation date (i. e. stat -f %SB) via terminal and convert them in that order into one pdf?



What if one jpg has been created today at 11:10 pm and a second one shortly after within the same minute at 11:10 pm? Are there seconds in the creation date, which can be taken into account?










share|improve this question
















On a Mac, how can I sort about 2400 jpg according to their creation date (i. e. stat -f %SB) via terminal and convert them in that order into one pdf?



What if one jpg has been created today at 11:10 pm and a second one shortly after within the same minute at 11:10 pm? Are there seconds in the creation date, which can be taken into account?







shell osx sort pdf jpeg






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 11 at 9:38









PRY

2,55831026




2,55831026










asked Jun 21 '17 at 21:10









Til HundTil Hund

9917




9917













  • You can do this easily with zsh (e.g. custom sorting). I don't have access to OSX so cannot post an answer but this should be piece of cake...

    – don_crissti
    Aug 5 '17 at 9:43



















  • You can do this easily with zsh (e.g. custom sorting). I don't have access to OSX so cannot post an answer but this should be piece of cake...

    – don_crissti
    Aug 5 '17 at 9:43

















You can do this easily with zsh (e.g. custom sorting). I don't have access to OSX so cannot post an answer but this should be piece of cake...

– don_crissti
Aug 5 '17 at 9:43





You can do this easily with zsh (e.g. custom sorting). I don't have access to OSX so cannot post an answer but this should be piece of cake...

– don_crissti
Aug 5 '17 at 9:43










3 Answers
3






active

oldest

votes


















1














A simple command line with ImageMagick convert works for me.



I tested with the following command line (in a directory with 14 png files), and there will be one picture per page in the pdf file.



convert  *.png out-parrot.pdf


But there can be problems with some versions of convert



It works as intended with the version of convert in Parrot 4.4



$convert --version
Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org


but it does not work with the version of convert in Ubuntu 18.04.1 LTS (up to date in February 2019)



$ convert --version
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org


This version is 'not authorized' to write pdf files



$ convert  *.png out-ubuntu.pdf
convert-im6.q16: not authorized `out-ubuntu.pdf' @ error/constitute.c/WriteImage/1037.




$ apt-cache policy imagemagick
imagemagick:
Installed: 8:6.9.7.4+dfsg-16ubuntu6.4
Candidate: 8:6.9.7.4+dfsg-16ubuntu6.4
Version table:
*** 8:6.9.7.4+dfsg-16ubuntu6.4 500
500 http://se.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
100 /var/lib/dpkg/status
8:6.9.7.4+dfsg-16ubuntu6 500
500 http://se.archive.ubuntu.com/ubuntu bionic/main amd64 Packages




Via an Ubuntu mailing list I had the following answer (that converting to pdf was turned off because of problems with ImageMagick vulnerabilities)





Is this a bug in ImageMagick convert, specifically for Ubuntu 18.04 LTS,
or is converting to pdf turned off by intention?




The change was intentional. See https://usn.ubuntu.com/3785-1/



Thanks, Jeremy Bicha







share|improve this answer

































    3














    It depends on the filesystem. For example, on my host, I am using the fourth extended filesystem (ext4), and stat reports thusly for files:



    $ touch foo; stat foo; rm foo
    File: 'foo'
    Size: 0 Blocks: 0 IO Block: 4096 regular empty file
    Device: fc00h/64512d Inode: 262155 Links: 1
    Access: (0664/-rw-rw-r--) Uid: ( 1000/ ownerusername) Gid: ( 1000/ ownerusername)
    Access: 2017-06-21 14:28:16.150323827 -0700
    Modify: 2017-06-21 14:28:16.150323827 -0700
    Change: 2017-06-21 14:28:16.150323827 -0700
    Birth: -


    So you can use the last-modified time as create time is something of a misnomer.



    find /path/to/images -type f -print0 -name *.jpg | xargs -0 stat -c "%y|%n" | sort | awk -F'|' '{print $2}'


    This somewhat cumbersome construct will give you a list of files in order by last modification time (provided you have no files with | in their names).



    Once you have and have reviewed this list, you can use Imagemagick's convert tool to assemble the PDF:



    convert <<list of files>> outputfile.pdf 


    Or, to do it all at once:



    convert $(find /path/to/images -type f -print0 -name *.jpg | xargs -0 stat -c "%y|%n" | sort | awk -F'|' '{print $2}') outputfile.pdf





    share|improve this answer


























    • The OP mentions nothing about parsing exif data, however.

      – DopeGhoti
      Jun 21 '17 at 21:51











    • DopeGhoti, thank you very much your reply. When I try the above command I get the following error message stat: illegal option -- c. It is true, the picture I have do not have EXIF data.

      – Til Hund
      Jun 22 '17 at 20:17











    • Do you know which filesystem is in question here? stat -c works for me in my tests.

      – DopeGhoti
      Jun 22 '17 at 20:31











    • I might add that I want to use the above command on a Mac. I did not mentioned it before as I thought it would be irrelevant to the question. The filesystem would be HFS Plus or Mac OS Extended (Journaled).

      – Til Hund
      Jun 23 '17 at 8:04













    • For a Mac, use stat -f "%a|%N".

      – DopeGhoti
      Jun 28 '17 at 16:05



















    0














    Install ImageMagick. Assuming the JPG images are in ~/images and the file names don't contain any spaces (nor any of [*?) and you have a directory ~/combined:



    convert -combine -append $(ls -tr ~/images/*.jpg) ~/combined/all.jpg


    or



      convert -combine -append $(ls -tr ~/images/*.jpg) ~/combined/all.pdf


    If the images are not the same size, you will get warnings. -append combines images top to bottom. Change to +append and images will combine left to right.



    Time: Although ls -l shows time down to hour:minute, Linux keeps track of the access, modify, and age/change times down to the nano second I believe. So sorting by ls -tr does account for even fractions of seconds.






    share|improve this answer





















    • 1





      Don't parse ls.

      – DopeGhoti
      Jun 21 '17 at 21:43











    • Thank you, Deathgrip, for answering. How can I convert the pictures into a single pdf as asked above?

      – Til Hund
      Jun 21 '17 at 21:43











    • @DopeGhoti - huh? the command works fine and I tested it using CentOS 7.

      – Deathgrip
      Jun 21 '17 at 21:46











    • It will fail if any of those file names contains [[:space:]]...

      – don_crissti
      Jun 21 '17 at 21:47











    • Trying to parse the output of an ls is an exercise which, while it may seem to work, is a terribly bad habit to get into for many many security-related reasons, which the link included in my answer goes into in great detail. More detail can be found here.

      – DopeGhoti
      Jun 21 '17 at 21:47













    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
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f372578%2fsort-jpg-according-to-creation-date-and-convert-to-single-pdf%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    A simple command line with ImageMagick convert works for me.



    I tested with the following command line (in a directory with 14 png files), and there will be one picture per page in the pdf file.



    convert  *.png out-parrot.pdf


    But there can be problems with some versions of convert



    It works as intended with the version of convert in Parrot 4.4



    $convert --version
    Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org


    but it does not work with the version of convert in Ubuntu 18.04.1 LTS (up to date in February 2019)



    $ convert --version
    Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org


    This version is 'not authorized' to write pdf files



    $ convert  *.png out-ubuntu.pdf
    convert-im6.q16: not authorized `out-ubuntu.pdf' @ error/constitute.c/WriteImage/1037.




    $ apt-cache policy imagemagick
    imagemagick:
    Installed: 8:6.9.7.4+dfsg-16ubuntu6.4
    Candidate: 8:6.9.7.4+dfsg-16ubuntu6.4
    Version table:
    *** 8:6.9.7.4+dfsg-16ubuntu6.4 500
    500 http://se.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
    500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
    100 /var/lib/dpkg/status
    8:6.9.7.4+dfsg-16ubuntu6 500
    500 http://se.archive.ubuntu.com/ubuntu bionic/main amd64 Packages




    Via an Ubuntu mailing list I had the following answer (that converting to pdf was turned off because of problems with ImageMagick vulnerabilities)





    Is this a bug in ImageMagick convert, specifically for Ubuntu 18.04 LTS,
    or is converting to pdf turned off by intention?




    The change was intentional. See https://usn.ubuntu.com/3785-1/



    Thanks, Jeremy Bicha







    share|improve this answer






























      1














      A simple command line with ImageMagick convert works for me.



      I tested with the following command line (in a directory with 14 png files), and there will be one picture per page in the pdf file.



      convert  *.png out-parrot.pdf


      But there can be problems with some versions of convert



      It works as intended with the version of convert in Parrot 4.4



      $convert --version
      Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org


      but it does not work with the version of convert in Ubuntu 18.04.1 LTS (up to date in February 2019)



      $ convert --version
      Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org


      This version is 'not authorized' to write pdf files



      $ convert  *.png out-ubuntu.pdf
      convert-im6.q16: not authorized `out-ubuntu.pdf' @ error/constitute.c/WriteImage/1037.




      $ apt-cache policy imagemagick
      imagemagick:
      Installed: 8:6.9.7.4+dfsg-16ubuntu6.4
      Candidate: 8:6.9.7.4+dfsg-16ubuntu6.4
      Version table:
      *** 8:6.9.7.4+dfsg-16ubuntu6.4 500
      500 http://se.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
      500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
      100 /var/lib/dpkg/status
      8:6.9.7.4+dfsg-16ubuntu6 500
      500 http://se.archive.ubuntu.com/ubuntu bionic/main amd64 Packages




      Via an Ubuntu mailing list I had the following answer (that converting to pdf was turned off because of problems with ImageMagick vulnerabilities)





      Is this a bug in ImageMagick convert, specifically for Ubuntu 18.04 LTS,
      or is converting to pdf turned off by intention?




      The change was intentional. See https://usn.ubuntu.com/3785-1/



      Thanks, Jeremy Bicha







      share|improve this answer




























        1












        1








        1







        A simple command line with ImageMagick convert works for me.



        I tested with the following command line (in a directory with 14 png files), and there will be one picture per page in the pdf file.



        convert  *.png out-parrot.pdf


        But there can be problems with some versions of convert



        It works as intended with the version of convert in Parrot 4.4



        $convert --version
        Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org


        but it does not work with the version of convert in Ubuntu 18.04.1 LTS (up to date in February 2019)



        $ convert --version
        Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org


        This version is 'not authorized' to write pdf files



        $ convert  *.png out-ubuntu.pdf
        convert-im6.q16: not authorized `out-ubuntu.pdf' @ error/constitute.c/WriteImage/1037.




        $ apt-cache policy imagemagick
        imagemagick:
        Installed: 8:6.9.7.4+dfsg-16ubuntu6.4
        Candidate: 8:6.9.7.4+dfsg-16ubuntu6.4
        Version table:
        *** 8:6.9.7.4+dfsg-16ubuntu6.4 500
        500 http://se.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
        100 /var/lib/dpkg/status
        8:6.9.7.4+dfsg-16ubuntu6 500
        500 http://se.archive.ubuntu.com/ubuntu bionic/main amd64 Packages




        Via an Ubuntu mailing list I had the following answer (that converting to pdf was turned off because of problems with ImageMagick vulnerabilities)





        Is this a bug in ImageMagick convert, specifically for Ubuntu 18.04 LTS,
        or is converting to pdf turned off by intention?




        The change was intentional. See https://usn.ubuntu.com/3785-1/



        Thanks, Jeremy Bicha







        share|improve this answer















        A simple command line with ImageMagick convert works for me.



        I tested with the following command line (in a directory with 14 png files), and there will be one picture per page in the pdf file.



        convert  *.png out-parrot.pdf


        But there can be problems with some versions of convert



        It works as intended with the version of convert in Parrot 4.4



        $convert --version
        Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org


        but it does not work with the version of convert in Ubuntu 18.04.1 LTS (up to date in February 2019)



        $ convert --version
        Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org


        This version is 'not authorized' to write pdf files



        $ convert  *.png out-ubuntu.pdf
        convert-im6.q16: not authorized `out-ubuntu.pdf' @ error/constitute.c/WriteImage/1037.




        $ apt-cache policy imagemagick
        imagemagick:
        Installed: 8:6.9.7.4+dfsg-16ubuntu6.4
        Candidate: 8:6.9.7.4+dfsg-16ubuntu6.4
        Version table:
        *** 8:6.9.7.4+dfsg-16ubuntu6.4 500
        500 http://se.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
        100 /var/lib/dpkg/status
        8:6.9.7.4+dfsg-16ubuntu6 500
        500 http://se.archive.ubuntu.com/ubuntu bionic/main amd64 Packages




        Via an Ubuntu mailing list I had the following answer (that converting to pdf was turned off because of problems with ImageMagick vulnerabilities)





        Is this a bug in ImageMagick convert, specifically for Ubuntu 18.04 LTS,
        or is converting to pdf turned off by intention?




        The change was intentional. See https://usn.ubuntu.com/3785-1/



        Thanks, Jeremy Bicha








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 12 at 19:48

























        answered Feb 11 at 12:07









        sudodussudodus

        1,54837




        1,54837

























            3














            It depends on the filesystem. For example, on my host, I am using the fourth extended filesystem (ext4), and stat reports thusly for files:



            $ touch foo; stat foo; rm foo
            File: 'foo'
            Size: 0 Blocks: 0 IO Block: 4096 regular empty file
            Device: fc00h/64512d Inode: 262155 Links: 1
            Access: (0664/-rw-rw-r--) Uid: ( 1000/ ownerusername) Gid: ( 1000/ ownerusername)
            Access: 2017-06-21 14:28:16.150323827 -0700
            Modify: 2017-06-21 14:28:16.150323827 -0700
            Change: 2017-06-21 14:28:16.150323827 -0700
            Birth: -


            So you can use the last-modified time as create time is something of a misnomer.



            find /path/to/images -type f -print0 -name *.jpg | xargs -0 stat -c "%y|%n" | sort | awk -F'|' '{print $2}'


            This somewhat cumbersome construct will give you a list of files in order by last modification time (provided you have no files with | in their names).



            Once you have and have reviewed this list, you can use Imagemagick's convert tool to assemble the PDF:



            convert <<list of files>> outputfile.pdf 


            Or, to do it all at once:



            convert $(find /path/to/images -type f -print0 -name *.jpg | xargs -0 stat -c "%y|%n" | sort | awk -F'|' '{print $2}') outputfile.pdf





            share|improve this answer


























            • The OP mentions nothing about parsing exif data, however.

              – DopeGhoti
              Jun 21 '17 at 21:51











            • DopeGhoti, thank you very much your reply. When I try the above command I get the following error message stat: illegal option -- c. It is true, the picture I have do not have EXIF data.

              – Til Hund
              Jun 22 '17 at 20:17











            • Do you know which filesystem is in question here? stat -c works for me in my tests.

              – DopeGhoti
              Jun 22 '17 at 20:31











            • I might add that I want to use the above command on a Mac. I did not mentioned it before as I thought it would be irrelevant to the question. The filesystem would be HFS Plus or Mac OS Extended (Journaled).

              – Til Hund
              Jun 23 '17 at 8:04













            • For a Mac, use stat -f "%a|%N".

              – DopeGhoti
              Jun 28 '17 at 16:05
















            3














            It depends on the filesystem. For example, on my host, I am using the fourth extended filesystem (ext4), and stat reports thusly for files:



            $ touch foo; stat foo; rm foo
            File: 'foo'
            Size: 0 Blocks: 0 IO Block: 4096 regular empty file
            Device: fc00h/64512d Inode: 262155 Links: 1
            Access: (0664/-rw-rw-r--) Uid: ( 1000/ ownerusername) Gid: ( 1000/ ownerusername)
            Access: 2017-06-21 14:28:16.150323827 -0700
            Modify: 2017-06-21 14:28:16.150323827 -0700
            Change: 2017-06-21 14:28:16.150323827 -0700
            Birth: -


            So you can use the last-modified time as create time is something of a misnomer.



            find /path/to/images -type f -print0 -name *.jpg | xargs -0 stat -c "%y|%n" | sort | awk -F'|' '{print $2}'


            This somewhat cumbersome construct will give you a list of files in order by last modification time (provided you have no files with | in their names).



            Once you have and have reviewed this list, you can use Imagemagick's convert tool to assemble the PDF:



            convert <<list of files>> outputfile.pdf 


            Or, to do it all at once:



            convert $(find /path/to/images -type f -print0 -name *.jpg | xargs -0 stat -c "%y|%n" | sort | awk -F'|' '{print $2}') outputfile.pdf





            share|improve this answer


























            • The OP mentions nothing about parsing exif data, however.

              – DopeGhoti
              Jun 21 '17 at 21:51











            • DopeGhoti, thank you very much your reply. When I try the above command I get the following error message stat: illegal option -- c. It is true, the picture I have do not have EXIF data.

              – Til Hund
              Jun 22 '17 at 20:17











            • Do you know which filesystem is in question here? stat -c works for me in my tests.

              – DopeGhoti
              Jun 22 '17 at 20:31











            • I might add that I want to use the above command on a Mac. I did not mentioned it before as I thought it would be irrelevant to the question. The filesystem would be HFS Plus or Mac OS Extended (Journaled).

              – Til Hund
              Jun 23 '17 at 8:04













            • For a Mac, use stat -f "%a|%N".

              – DopeGhoti
              Jun 28 '17 at 16:05














            3












            3








            3







            It depends on the filesystem. For example, on my host, I am using the fourth extended filesystem (ext4), and stat reports thusly for files:



            $ touch foo; stat foo; rm foo
            File: 'foo'
            Size: 0 Blocks: 0 IO Block: 4096 regular empty file
            Device: fc00h/64512d Inode: 262155 Links: 1
            Access: (0664/-rw-rw-r--) Uid: ( 1000/ ownerusername) Gid: ( 1000/ ownerusername)
            Access: 2017-06-21 14:28:16.150323827 -0700
            Modify: 2017-06-21 14:28:16.150323827 -0700
            Change: 2017-06-21 14:28:16.150323827 -0700
            Birth: -


            So you can use the last-modified time as create time is something of a misnomer.



            find /path/to/images -type f -print0 -name *.jpg | xargs -0 stat -c "%y|%n" | sort | awk -F'|' '{print $2}'


            This somewhat cumbersome construct will give you a list of files in order by last modification time (provided you have no files with | in their names).



            Once you have and have reviewed this list, you can use Imagemagick's convert tool to assemble the PDF:



            convert <<list of files>> outputfile.pdf 


            Or, to do it all at once:



            convert $(find /path/to/images -type f -print0 -name *.jpg | xargs -0 stat -c "%y|%n" | sort | awk -F'|' '{print $2}') outputfile.pdf





            share|improve this answer















            It depends on the filesystem. For example, on my host, I am using the fourth extended filesystem (ext4), and stat reports thusly for files:



            $ touch foo; stat foo; rm foo
            File: 'foo'
            Size: 0 Blocks: 0 IO Block: 4096 regular empty file
            Device: fc00h/64512d Inode: 262155 Links: 1
            Access: (0664/-rw-rw-r--) Uid: ( 1000/ ownerusername) Gid: ( 1000/ ownerusername)
            Access: 2017-06-21 14:28:16.150323827 -0700
            Modify: 2017-06-21 14:28:16.150323827 -0700
            Change: 2017-06-21 14:28:16.150323827 -0700
            Birth: -


            So you can use the last-modified time as create time is something of a misnomer.



            find /path/to/images -type f -print0 -name *.jpg | xargs -0 stat -c "%y|%n" | sort | awk -F'|' '{print $2}'


            This somewhat cumbersome construct will give you a list of files in order by last modification time (provided you have no files with | in their names).



            Once you have and have reviewed this list, you can use Imagemagick's convert tool to assemble the PDF:



            convert <<list of files>> outputfile.pdf 


            Or, to do it all at once:



            convert $(find /path/to/images -type f -print0 -name *.jpg | xargs -0 stat -c "%y|%n" | sort | awk -F'|' '{print $2}') outputfile.pdf






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 11 at 9:09









            Pang

            12315




            12315










            answered Jun 21 '17 at 21:42









            DopeGhotiDopeGhoti

            45.8k55988




            45.8k55988













            • The OP mentions nothing about parsing exif data, however.

              – DopeGhoti
              Jun 21 '17 at 21:51











            • DopeGhoti, thank you very much your reply. When I try the above command I get the following error message stat: illegal option -- c. It is true, the picture I have do not have EXIF data.

              – Til Hund
              Jun 22 '17 at 20:17











            • Do you know which filesystem is in question here? stat -c works for me in my tests.

              – DopeGhoti
              Jun 22 '17 at 20:31











            • I might add that I want to use the above command on a Mac. I did not mentioned it before as I thought it would be irrelevant to the question. The filesystem would be HFS Plus or Mac OS Extended (Journaled).

              – Til Hund
              Jun 23 '17 at 8:04













            • For a Mac, use stat -f "%a|%N".

              – DopeGhoti
              Jun 28 '17 at 16:05



















            • The OP mentions nothing about parsing exif data, however.

              – DopeGhoti
              Jun 21 '17 at 21:51











            • DopeGhoti, thank you very much your reply. When I try the above command I get the following error message stat: illegal option -- c. It is true, the picture I have do not have EXIF data.

              – Til Hund
              Jun 22 '17 at 20:17











            • Do you know which filesystem is in question here? stat -c works for me in my tests.

              – DopeGhoti
              Jun 22 '17 at 20:31











            • I might add that I want to use the above command on a Mac. I did not mentioned it before as I thought it would be irrelevant to the question. The filesystem would be HFS Plus or Mac OS Extended (Journaled).

              – Til Hund
              Jun 23 '17 at 8:04













            • For a Mac, use stat -f "%a|%N".

              – DopeGhoti
              Jun 28 '17 at 16:05

















            The OP mentions nothing about parsing exif data, however.

            – DopeGhoti
            Jun 21 '17 at 21:51





            The OP mentions nothing about parsing exif data, however.

            – DopeGhoti
            Jun 21 '17 at 21:51













            DopeGhoti, thank you very much your reply. When I try the above command I get the following error message stat: illegal option -- c. It is true, the picture I have do not have EXIF data.

            – Til Hund
            Jun 22 '17 at 20:17





            DopeGhoti, thank you very much your reply. When I try the above command I get the following error message stat: illegal option -- c. It is true, the picture I have do not have EXIF data.

            – Til Hund
            Jun 22 '17 at 20:17













            Do you know which filesystem is in question here? stat -c works for me in my tests.

            – DopeGhoti
            Jun 22 '17 at 20:31





            Do you know which filesystem is in question here? stat -c works for me in my tests.

            – DopeGhoti
            Jun 22 '17 at 20:31













            I might add that I want to use the above command on a Mac. I did not mentioned it before as I thought it would be irrelevant to the question. The filesystem would be HFS Plus or Mac OS Extended (Journaled).

            – Til Hund
            Jun 23 '17 at 8:04







            I might add that I want to use the above command on a Mac. I did not mentioned it before as I thought it would be irrelevant to the question. The filesystem would be HFS Plus or Mac OS Extended (Journaled).

            – Til Hund
            Jun 23 '17 at 8:04















            For a Mac, use stat -f "%a|%N".

            – DopeGhoti
            Jun 28 '17 at 16:05





            For a Mac, use stat -f "%a|%N".

            – DopeGhoti
            Jun 28 '17 at 16:05











            0














            Install ImageMagick. Assuming the JPG images are in ~/images and the file names don't contain any spaces (nor any of [*?) and you have a directory ~/combined:



            convert -combine -append $(ls -tr ~/images/*.jpg) ~/combined/all.jpg


            or



              convert -combine -append $(ls -tr ~/images/*.jpg) ~/combined/all.pdf


            If the images are not the same size, you will get warnings. -append combines images top to bottom. Change to +append and images will combine left to right.



            Time: Although ls -l shows time down to hour:minute, Linux keeps track of the access, modify, and age/change times down to the nano second I believe. So sorting by ls -tr does account for even fractions of seconds.






            share|improve this answer





















            • 1





              Don't parse ls.

              – DopeGhoti
              Jun 21 '17 at 21:43











            • Thank you, Deathgrip, for answering. How can I convert the pictures into a single pdf as asked above?

              – Til Hund
              Jun 21 '17 at 21:43











            • @DopeGhoti - huh? the command works fine and I tested it using CentOS 7.

              – Deathgrip
              Jun 21 '17 at 21:46











            • It will fail if any of those file names contains [[:space:]]...

              – don_crissti
              Jun 21 '17 at 21:47











            • Trying to parse the output of an ls is an exercise which, while it may seem to work, is a terribly bad habit to get into for many many security-related reasons, which the link included in my answer goes into in great detail. More detail can be found here.

              – DopeGhoti
              Jun 21 '17 at 21:47


















            0














            Install ImageMagick. Assuming the JPG images are in ~/images and the file names don't contain any spaces (nor any of [*?) and you have a directory ~/combined:



            convert -combine -append $(ls -tr ~/images/*.jpg) ~/combined/all.jpg


            or



              convert -combine -append $(ls -tr ~/images/*.jpg) ~/combined/all.pdf


            If the images are not the same size, you will get warnings. -append combines images top to bottom. Change to +append and images will combine left to right.



            Time: Although ls -l shows time down to hour:minute, Linux keeps track of the access, modify, and age/change times down to the nano second I believe. So sorting by ls -tr does account for even fractions of seconds.






            share|improve this answer





















            • 1





              Don't parse ls.

              – DopeGhoti
              Jun 21 '17 at 21:43











            • Thank you, Deathgrip, for answering. How can I convert the pictures into a single pdf as asked above?

              – Til Hund
              Jun 21 '17 at 21:43











            • @DopeGhoti - huh? the command works fine and I tested it using CentOS 7.

              – Deathgrip
              Jun 21 '17 at 21:46











            • It will fail if any of those file names contains [[:space:]]...

              – don_crissti
              Jun 21 '17 at 21:47











            • Trying to parse the output of an ls is an exercise which, while it may seem to work, is a terribly bad habit to get into for many many security-related reasons, which the link included in my answer goes into in great detail. More detail can be found here.

              – DopeGhoti
              Jun 21 '17 at 21:47
















            0












            0








            0







            Install ImageMagick. Assuming the JPG images are in ~/images and the file names don't contain any spaces (nor any of [*?) and you have a directory ~/combined:



            convert -combine -append $(ls -tr ~/images/*.jpg) ~/combined/all.jpg


            or



              convert -combine -append $(ls -tr ~/images/*.jpg) ~/combined/all.pdf


            If the images are not the same size, you will get warnings. -append combines images top to bottom. Change to +append and images will combine left to right.



            Time: Although ls -l shows time down to hour:minute, Linux keeps track of the access, modify, and age/change times down to the nano second I believe. So sorting by ls -tr does account for even fractions of seconds.






            share|improve this answer















            Install ImageMagick. Assuming the JPG images are in ~/images and the file names don't contain any spaces (nor any of [*?) and you have a directory ~/combined:



            convert -combine -append $(ls -tr ~/images/*.jpg) ~/combined/all.jpg


            or



              convert -combine -append $(ls -tr ~/images/*.jpg) ~/combined/all.pdf


            If the images are not the same size, you will get warnings. -append combines images top to bottom. Change to +append and images will combine left to right.



            Time: Although ls -l shows time down to hour:minute, Linux keeps track of the access, modify, and age/change times down to the nano second I believe. So sorting by ls -tr does account for even fractions of seconds.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 22 '17 at 23:33









            Gilles

            539k12810891606




            539k12810891606










            answered Jun 21 '17 at 21:37









            DeathgripDeathgrip

            1,424313




            1,424313








            • 1





              Don't parse ls.

              – DopeGhoti
              Jun 21 '17 at 21:43











            • Thank you, Deathgrip, for answering. How can I convert the pictures into a single pdf as asked above?

              – Til Hund
              Jun 21 '17 at 21:43











            • @DopeGhoti - huh? the command works fine and I tested it using CentOS 7.

              – Deathgrip
              Jun 21 '17 at 21:46











            • It will fail if any of those file names contains [[:space:]]...

              – don_crissti
              Jun 21 '17 at 21:47











            • Trying to parse the output of an ls is an exercise which, while it may seem to work, is a terribly bad habit to get into for many many security-related reasons, which the link included in my answer goes into in great detail. More detail can be found here.

              – DopeGhoti
              Jun 21 '17 at 21:47
















            • 1





              Don't parse ls.

              – DopeGhoti
              Jun 21 '17 at 21:43











            • Thank you, Deathgrip, for answering. How can I convert the pictures into a single pdf as asked above?

              – Til Hund
              Jun 21 '17 at 21:43











            • @DopeGhoti - huh? the command works fine and I tested it using CentOS 7.

              – Deathgrip
              Jun 21 '17 at 21:46











            • It will fail if any of those file names contains [[:space:]]...

              – don_crissti
              Jun 21 '17 at 21:47











            • Trying to parse the output of an ls is an exercise which, while it may seem to work, is a terribly bad habit to get into for many many security-related reasons, which the link included in my answer goes into in great detail. More detail can be found here.

              – DopeGhoti
              Jun 21 '17 at 21:47










            1




            1





            Don't parse ls.

            – DopeGhoti
            Jun 21 '17 at 21:43





            Don't parse ls.

            – DopeGhoti
            Jun 21 '17 at 21:43













            Thank you, Deathgrip, for answering. How can I convert the pictures into a single pdf as asked above?

            – Til Hund
            Jun 21 '17 at 21:43





            Thank you, Deathgrip, for answering. How can I convert the pictures into a single pdf as asked above?

            – Til Hund
            Jun 21 '17 at 21:43













            @DopeGhoti - huh? the command works fine and I tested it using CentOS 7.

            – Deathgrip
            Jun 21 '17 at 21:46





            @DopeGhoti - huh? the command works fine and I tested it using CentOS 7.

            – Deathgrip
            Jun 21 '17 at 21:46













            It will fail if any of those file names contains [[:space:]]...

            – don_crissti
            Jun 21 '17 at 21:47





            It will fail if any of those file names contains [[:space:]]...

            – don_crissti
            Jun 21 '17 at 21:47













            Trying to parse the output of an ls is an exercise which, while it may seem to work, is a terribly bad habit to get into for many many security-related reasons, which the link included in my answer goes into in great detail. More detail can be found here.

            – DopeGhoti
            Jun 21 '17 at 21:47







            Trying to parse the output of an ls is an exercise which, while it may seem to work, is a terribly bad habit to get into for many many security-related reasons, which the link included in my answer goes into in great detail. More detail can be found here.

            – DopeGhoti
            Jun 21 '17 at 21:47




















            draft saved

            draft discarded




















































            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%2f372578%2fsort-jpg-according-to-creation-date-and-convert-to-single-pdf%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

            How to make a Squid Proxy server?

            第一次世界大戦

            Touch on Surface Book