How to copy file from a list to a new folder? The 2019 Stack Overflow Developer Survey Results...

Drawing arrows from one table cell reference to another

Why doesn't a hydraulic lever violate conservation of energy?

Is an up-to-date browser secure on an out-of-date OS?

How to read αἱμύλιος or when to aspirate

Sub-subscripts in strings cause different spacings than subscripts

How to determine omitted units in a publication

Are there continuous functions who are the same in an interval but differ in at least one other point?

Do I have Disadvantage attacking with an off-hand weapon?

Did the new image of black hole confirm the general theory of relativity?

Does Parliament hold absolute power in the UK?

Can each chord in a progression create its own key?

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

University's motivation for having tenure-track positions

should truth entail possible truth

Why are PDP-7-style microprogrammed instructions out of vogue?

Why did Peik Lin say, "I'm not an animal"?

Why not take a picture of a closer black hole?

Can the DM override racial traits?

Is there a writing software that you can sort scenes like slides in PowerPoint?

Presidential Pardon

Can we generate random numbers using irrational numbers like π and e?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

US Healthcare consultation for visitors

Accepted by European university, rejected by all American ones I applied to? Possible reasons?



How to copy file from a list to a new folder?



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Copy/move a list of files to a new directoryHow to separate a given type of file from others?Recursively copying filesmoving the file from one folder to another folderCopy unmatched strings in from one file to another, bulkread file names from files for command lineBash Script to Drag and Drop a File to New LocationMoving only those files that appear in the listFind, Duplicate, Rename and Copy to this foldercopying files resulting from using grep into a new folderSearch folder, find and copy files to new folder corresponding file ending





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







2















I have a file file1.txt located in a trial folder containing the location of image files. I want to read the list, and copy the image files to a new folder, test_folder.



The entries in file1.txt look like:



./trial/data/image1.jpg
./trial/data/image2.jpg


etc.



I tried to use a similar question to solve the problem: Copy/move a list of files to a new directory



Attempt



while read file; do cp "$file" /trial/test_folder; done < /trial/file1.txt


I get the error "bash: /trial/file1.txt: No such file or directory". Any help would be great!










share|improve this question

























  • I have updated the question to include that - thanks!

    – Shane B
    Mar 22 at 10:16


















2















I have a file file1.txt located in a trial folder containing the location of image files. I want to read the list, and copy the image files to a new folder, test_folder.



The entries in file1.txt look like:



./trial/data/image1.jpg
./trial/data/image2.jpg


etc.



I tried to use a similar question to solve the problem: Copy/move a list of files to a new directory



Attempt



while read file; do cp "$file" /trial/test_folder; done < /trial/file1.txt


I get the error "bash: /trial/file1.txt: No such file or directory". Any help would be great!










share|improve this question

























  • I have updated the question to include that - thanks!

    – Shane B
    Mar 22 at 10:16














2












2








2








I have a file file1.txt located in a trial folder containing the location of image files. I want to read the list, and copy the image files to a new folder, test_folder.



The entries in file1.txt look like:



./trial/data/image1.jpg
./trial/data/image2.jpg


etc.



I tried to use a similar question to solve the problem: Copy/move a list of files to a new directory



Attempt



while read file; do cp "$file" /trial/test_folder; done < /trial/file1.txt


I get the error "bash: /trial/file1.txt: No such file or directory". Any help would be great!










share|improve this question
















I have a file file1.txt located in a trial folder containing the location of image files. I want to read the list, and copy the image files to a new folder, test_folder.



The entries in file1.txt look like:



./trial/data/image1.jpg
./trial/data/image2.jpg


etc.



I tried to use a similar question to solve the problem: Copy/move a list of files to a new directory



Attempt



while read file; do cp "$file" /trial/test_folder; done < /trial/file1.txt


I get the error "bash: /trial/file1.txt: No such file or directory". Any help would be great!







command-line bash copy






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 10:20







Shane B

















asked Mar 22 at 9:58









Shane BShane B

133




133













  • I have updated the question to include that - thanks!

    – Shane B
    Mar 22 at 10:16



















  • I have updated the question to include that - thanks!

    – Shane B
    Mar 22 at 10:16

















I have updated the question to include that - thanks!

– Shane B
Mar 22 at 10:16





I have updated the question to include that - thanks!

– Shane B
Mar 22 at 10:16










2 Answers
2






active

oldest

votes


















4














The error you are getting is because you are reading /trial/file1.txt and not ./trial/file1.txt. That means the shell is trying to find a directory called trial which is under the root directory (/). If you want a path that is relative to your current directory, you can just use:



while read file; do cp "$file" trial/test_folder; done < trial/file1.txt


Or,



while read file; do cp "$file" ./trial/test_folder; done < ./trial/file1.txt


Or, you can use the full path:



while read file; do cp "$file" /home/shane/trial/test_folder; done < /home/shane/trial/file1.txt





share|improve this answer
























  • Thanks so much! That worked. I am very new to Linux so that was a great help

    – Shane B
    Mar 22 at 10:23



















2














Another way is to use xargs and cp --target-directory=... thusly:



xargs -r <trial/file1.txt cp --target-directory=./trial/test_folder





share|improve this answer
























    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2faskubuntu.com%2fquestions%2f1127773%2fhow-to-copy-file-from-a-list-to-a-new-folder%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    The error you are getting is because you are reading /trial/file1.txt and not ./trial/file1.txt. That means the shell is trying to find a directory called trial which is under the root directory (/). If you want a path that is relative to your current directory, you can just use:



    while read file; do cp "$file" trial/test_folder; done < trial/file1.txt


    Or,



    while read file; do cp "$file" ./trial/test_folder; done < ./trial/file1.txt


    Or, you can use the full path:



    while read file; do cp "$file" /home/shane/trial/test_folder; done < /home/shane/trial/file1.txt





    share|improve this answer
























    • Thanks so much! That worked. I am very new to Linux so that was a great help

      – Shane B
      Mar 22 at 10:23
















    4














    The error you are getting is because you are reading /trial/file1.txt and not ./trial/file1.txt. That means the shell is trying to find a directory called trial which is under the root directory (/). If you want a path that is relative to your current directory, you can just use:



    while read file; do cp "$file" trial/test_folder; done < trial/file1.txt


    Or,



    while read file; do cp "$file" ./trial/test_folder; done < ./trial/file1.txt


    Or, you can use the full path:



    while read file; do cp "$file" /home/shane/trial/test_folder; done < /home/shane/trial/file1.txt





    share|improve this answer
























    • Thanks so much! That worked. I am very new to Linux so that was a great help

      – Shane B
      Mar 22 at 10:23














    4












    4








    4







    The error you are getting is because you are reading /trial/file1.txt and not ./trial/file1.txt. That means the shell is trying to find a directory called trial which is under the root directory (/). If you want a path that is relative to your current directory, you can just use:



    while read file; do cp "$file" trial/test_folder; done < trial/file1.txt


    Or,



    while read file; do cp "$file" ./trial/test_folder; done < ./trial/file1.txt


    Or, you can use the full path:



    while read file; do cp "$file" /home/shane/trial/test_folder; done < /home/shane/trial/file1.txt





    share|improve this answer













    The error you are getting is because you are reading /trial/file1.txt and not ./trial/file1.txt. That means the shell is trying to find a directory called trial which is under the root directory (/). If you want a path that is relative to your current directory, you can just use:



    while read file; do cp "$file" trial/test_folder; done < trial/file1.txt


    Or,



    while read file; do cp "$file" ./trial/test_folder; done < ./trial/file1.txt


    Or, you can use the full path:



    while read file; do cp "$file" /home/shane/trial/test_folder; done < /home/shane/trial/file1.txt






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 22 at 10:20









    terdonterdon

    67.7k13139223




    67.7k13139223













    • Thanks so much! That worked. I am very new to Linux so that was a great help

      – Shane B
      Mar 22 at 10:23



















    • Thanks so much! That worked. I am very new to Linux so that was a great help

      – Shane B
      Mar 22 at 10:23

















    Thanks so much! That worked. I am very new to Linux so that was a great help

    – Shane B
    Mar 22 at 10:23





    Thanks so much! That worked. I am very new to Linux so that was a great help

    – Shane B
    Mar 22 at 10:23













    2














    Another way is to use xargs and cp --target-directory=... thusly:



    xargs -r <trial/file1.txt cp --target-directory=./trial/test_folder





    share|improve this answer




























      2














      Another way is to use xargs and cp --target-directory=... thusly:



      xargs -r <trial/file1.txt cp --target-directory=./trial/test_folder





      share|improve this answer


























        2












        2








        2







        Another way is to use xargs and cp --target-directory=... thusly:



        xargs -r <trial/file1.txt cp --target-directory=./trial/test_folder





        share|improve this answer













        Another way is to use xargs and cp --target-directory=... thusly:



        xargs -r <trial/file1.txt cp --target-directory=./trial/test_folder






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 22 at 12:36









        waltinatorwaltinator

        23k74169




        23k74169






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • 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%2faskubuntu.com%2fquestions%2f1127773%2fhow-to-copy-file-from-a-list-to-a-new-folder%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

            Magento 2 - Add success message with knockout Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Success / Error message on ajax request$.widget is not a function when loading a homepage after add custom jQuery on custom themeHow can bind jQuery to current document in Magento 2 When template load by ajaxRedirect page using plugin in Magento 2Magento 2 - Update quantity and totals of cart page without page reload?Magento 2: Quote data not loaded on knockout checkoutMagento 2 : I need to change add to cart success message after adding product into cart through pluginMagento 2.2.5 How to add additional products to cart from new checkout step?Magento 2 Add error/success message with knockoutCan't validate Post Code on checkout page

            Fil:Tokke komm.svg

            Where did Arya get these scars? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why did Arya refuse to end it?Has the pronunciation of Arya Stark's name changed?Has Arya forgiven people?Why did Arya Stark lose her vision?Why can Arya still use the faces?Has the Narrow Sea become narrower?Does Arya Stark know how to make poisons outside of the House of Black and White?Why did Nymeria leave Arya?Why did Arya not kill the Lannister soldiers she encountered in the Riverlands?What is the current canonical age of Sansa, Bran and Arya Stark?