Copy files from one folder to another folder within specific date range

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I am already using below command to copy files from a specific date.



Previously I used this command and it worked well but now it was showing an error:



-bash: /bin/cp: Argument list too long


Commends used:



cd /share/new/
cp `find . -type f -newermt '16 july 2018'` /share/test


I need to copy all files in the folder "new" from July 20th to today date. How can I achieve this?










share|improve this question



























    up vote
    2
    down vote

    favorite












    I am already using below command to copy files from a specific date.



    Previously I used this command and it worked well but now it was showing an error:



    -bash: /bin/cp: Argument list too long


    Commends used:



    cd /share/new/
    cp `find . -type f -newermt '16 july 2018'` /share/test


    I need to copy all files in the folder "new" from July 20th to today date. How can I achieve this?










    share|improve this question

























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I am already using below command to copy files from a specific date.



      Previously I used this command and it worked well but now it was showing an error:



      -bash: /bin/cp: Argument list too long


      Commends used:



      cd /share/new/
      cp `find . -type f -newermt '16 july 2018'` /share/test


      I need to copy all files in the folder "new" from July 20th to today date. How can I achieve this?










      share|improve this question















      I am already using below command to copy files from a specific date.



      Previously I used this command and it worked well but now it was showing an error:



      -bash: /bin/cp: Argument list too long


      Commends used:



      cd /share/new/
      cp `find . -type f -newermt '16 july 2018'` /share/test


      I need to copy all files in the folder "new" from July 20th to today date. How can I achieve this?







      command-line bash copy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 18 mins ago









      Videonauth

      22.4k116897




      22.4k116897










      asked 21 mins ago









      Venki

      204




      204




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          Don't use cp directly with the output of find.



          It might passes way many too files in a single step (and that's why you get the error Argument list too long).



          Use the -exec parameter of find, which execute the given command passing a every matched file to cp, one at a time:



          cd /share/new/
          find . -type f -newermt '16 july 2018' -exec cp /share/test ;





          share|improve this answer




















          • find: missing argument to `-exec'
            – Venki
            12 mins ago










          • @Venki if you type find . -type f -newermt '16 july 2018' does any results appear? It might be that no files match your query. Pay attention to the last ; , too.
            – Mr Shunz
            7 mins ago











          • its working :: "" find . -type f -newermt '16 july 2018' -exec cp /share/test/ ; "" missing "/" after test because test is a directory
            – Venki
            1 min ago


















          up vote
          3
          down vote













          use find -exec:



          find /share/new/ -type f -newermt '16 july 2018' -exec cp /share/test ;





          share|improve this answer




















          • getting same error for your command also find: missing argument to `-exec'
            – Venki
            9 mins ago











          • I think your missing the ; at the end.
            – RoVo
            6 mins ago











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          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',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1078245%2fcopy-files-from-one-folder-to-another-folder-within-specific-date-range%23new-answer', 'question_page');

          );

          Post as a guest






























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          Don't use cp directly with the output of find.



          It might passes way many too files in a single step (and that's why you get the error Argument list too long).



          Use the -exec parameter of find, which execute the given command passing a every matched file to cp, one at a time:



          cd /share/new/
          find . -type f -newermt '16 july 2018' -exec cp /share/test ;





          share|improve this answer




















          • find: missing argument to `-exec'
            – Venki
            12 mins ago










          • @Venki if you type find . -type f -newermt '16 july 2018' does any results appear? It might be that no files match your query. Pay attention to the last ; , too.
            – Mr Shunz
            7 mins ago











          • its working :: "" find . -type f -newermt '16 july 2018' -exec cp /share/test/ ; "" missing "/" after test because test is a directory
            – Venki
            1 min ago















          up vote
          3
          down vote



          accepted










          Don't use cp directly with the output of find.



          It might passes way many too files in a single step (and that's why you get the error Argument list too long).



          Use the -exec parameter of find, which execute the given command passing a every matched file to cp, one at a time:



          cd /share/new/
          find . -type f -newermt '16 july 2018' -exec cp /share/test ;





          share|improve this answer




















          • find: missing argument to `-exec'
            – Venki
            12 mins ago










          • @Venki if you type find . -type f -newermt '16 july 2018' does any results appear? It might be that no files match your query. Pay attention to the last ; , too.
            – Mr Shunz
            7 mins ago











          • its working :: "" find . -type f -newermt '16 july 2018' -exec cp /share/test/ ; "" missing "/" after test because test is a directory
            – Venki
            1 min ago













          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          Don't use cp directly with the output of find.



          It might passes way many too files in a single step (and that's why you get the error Argument list too long).



          Use the -exec parameter of find, which execute the given command passing a every matched file to cp, one at a time:



          cd /share/new/
          find . -type f -newermt '16 july 2018' -exec cp /share/test ;





          share|improve this answer












          Don't use cp directly with the output of find.



          It might passes way many too files in a single step (and that's why you get the error Argument list too long).



          Use the -exec parameter of find, which execute the given command passing a every matched file to cp, one at a time:



          cd /share/new/
          find . -type f -newermt '16 july 2018' -exec cp /share/test ;






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 16 mins ago









          Mr Shunz

          1,9361319




          1,9361319











          • find: missing argument to `-exec'
            – Venki
            12 mins ago










          • @Venki if you type find . -type f -newermt '16 july 2018' does any results appear? It might be that no files match your query. Pay attention to the last ; , too.
            – Mr Shunz
            7 mins ago











          • its working :: "" find . -type f -newermt '16 july 2018' -exec cp /share/test/ ; "" missing "/" after test because test is a directory
            – Venki
            1 min ago

















          • find: missing argument to `-exec'
            – Venki
            12 mins ago










          • @Venki if you type find . -type f -newermt '16 july 2018' does any results appear? It might be that no files match your query. Pay attention to the last ; , too.
            – Mr Shunz
            7 mins ago











          • its working :: "" find . -type f -newermt '16 july 2018' -exec cp /share/test/ ; "" missing "/" after test because test is a directory
            – Venki
            1 min ago
















          find: missing argument to `-exec'
          – Venki
          12 mins ago




          find: missing argument to `-exec'
          – Venki
          12 mins ago












          @Venki if you type find . -type f -newermt '16 july 2018' does any results appear? It might be that no files match your query. Pay attention to the last ; , too.
          – Mr Shunz
          7 mins ago





          @Venki if you type find . -type f -newermt '16 july 2018' does any results appear? It might be that no files match your query. Pay attention to the last ; , too.
          – Mr Shunz
          7 mins ago













          its working :: "" find . -type f -newermt '16 july 2018' -exec cp /share/test/ ; "" missing "/" after test because test is a directory
          – Venki
          1 min ago





          its working :: "" find . -type f -newermt '16 july 2018' -exec cp /share/test/ ; "" missing "/" after test because test is a directory
          – Venki
          1 min ago













          up vote
          3
          down vote













          use find -exec:



          find /share/new/ -type f -newermt '16 july 2018' -exec cp /share/test ;





          share|improve this answer




















          • getting same error for your command also find: missing argument to `-exec'
            – Venki
            9 mins ago











          • I think your missing the ; at the end.
            – RoVo
            6 mins ago















          up vote
          3
          down vote













          use find -exec:



          find /share/new/ -type f -newermt '16 july 2018' -exec cp /share/test ;





          share|improve this answer




















          • getting same error for your command also find: missing argument to `-exec'
            – Venki
            9 mins ago











          • I think your missing the ; at the end.
            – RoVo
            6 mins ago













          up vote
          3
          down vote










          up vote
          3
          down vote









          use find -exec:



          find /share/new/ -type f -newermt '16 july 2018' -exec cp /share/test ;





          share|improve this answer












          use find -exec:



          find /share/new/ -type f -newermt '16 july 2018' -exec cp /share/test ;






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 17 mins ago









          RoVo

          5,6341237




          5,6341237











          • getting same error for your command also find: missing argument to `-exec'
            – Venki
            9 mins ago











          • I think your missing the ; at the end.
            – RoVo
            6 mins ago

















          • getting same error for your command also find: missing argument to `-exec'
            – Venki
            9 mins ago











          • I think your missing the ; at the end.
            – RoVo
            6 mins ago
















          getting same error for your command also find: missing argument to `-exec'
          – Venki
          9 mins ago





          getting same error for your command also find: missing argument to `-exec'
          – Venki
          9 mins ago













          I think your missing the ; at the end.
          – RoVo
          6 mins ago





          I think your missing the ; at the end.
          – RoVo
          6 mins ago


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1078245%2fcopy-files-from-one-folder-to-another-folder-within-specific-date-range%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          What does second last employer means? [closed]

          List of Gilmore Girls characters

          Confectionery