Copy a file to a folder, which has the same name as the original

Multi tool use
Multi tool use

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











up vote
-1
down vote

favorite












Hopefully, this should be an easy question for the experienced.



I have a list of folders (x1,x2, ..., xn) in a folder called "origin" (i.e. /origin/x1, /origin/x2 etc).



I want to take a particular file (im1.tif in my case) from each folder x1,x2, ..., xn in /origin and copy it to a folder in a destination folder called 'dest', which has the same name (i.e. /dest/x1, /dest/x2 etc).



Could someone help me with this?



Thank you!







share|improve this question




















  • idownvotedbecau.se/noattempt
    – Murphy
    Dec 22 '17 at 13:03














up vote
-1
down vote

favorite












Hopefully, this should be an easy question for the experienced.



I have a list of folders (x1,x2, ..., xn) in a folder called "origin" (i.e. /origin/x1, /origin/x2 etc).



I want to take a particular file (im1.tif in my case) from each folder x1,x2, ..., xn in /origin and copy it to a folder in a destination folder called 'dest', which has the same name (i.e. /dest/x1, /dest/x2 etc).



Could someone help me with this?



Thank you!







share|improve this question




















  • idownvotedbecau.se/noattempt
    – Murphy
    Dec 22 '17 at 13:03












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











Hopefully, this should be an easy question for the experienced.



I have a list of folders (x1,x2, ..., xn) in a folder called "origin" (i.e. /origin/x1, /origin/x2 etc).



I want to take a particular file (im1.tif in my case) from each folder x1,x2, ..., xn in /origin and copy it to a folder in a destination folder called 'dest', which has the same name (i.e. /dest/x1, /dest/x2 etc).



Could someone help me with this?



Thank you!







share|improve this question












Hopefully, this should be an easy question for the experienced.



I have a list of folders (x1,x2, ..., xn) in a folder called "origin" (i.e. /origin/x1, /origin/x2 etc).



I want to take a particular file (im1.tif in my case) from each folder x1,x2, ..., xn in /origin and copy it to a folder in a destination folder called 'dest', which has the same name (i.e. /dest/x1, /dest/x2 etc).



Could someone help me with this?



Thank you!









share|improve this question











share|improve this question




share|improve this question










asked Dec 22 '17 at 12:24









Adam Gosztolai

30036




30036











  • idownvotedbecau.se/noattempt
    – Murphy
    Dec 22 '17 at 13:03
















  • idownvotedbecau.se/noattempt
    – Murphy
    Dec 22 '17 at 13:03















idownvotedbecau.se/noattempt
– Murphy
Dec 22 '17 at 13:03




idownvotedbecau.se/noattempt
– Murphy
Dec 22 '17 at 13:03










1 Answer
1






active

oldest

votes

















up vote
0
down vote













find + bash solution:



find /origin -type f -name "*.tif" -exec bash -c 
'd="$(dirname $1)"; d=$d##*/; fn=$1##*/;
[ -d "/dest/$d" ] && cp "$1" "/dest/$d/$fn"; ' _ ;





share|improve this answer




















    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2funix.stackexchange.com%2fquestions%2f412494%2fcopy-a-file-to-a-folder-which-has-the-same-name-as-the-original%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    find + bash solution:



    find /origin -type f -name "*.tif" -exec bash -c 
    'd="$(dirname $1)"; d=$d##*/; fn=$1##*/;
    [ -d "/dest/$d" ] && cp "$1" "/dest/$d/$fn"; ' _ ;





    share|improve this answer
























      up vote
      0
      down vote













      find + bash solution:



      find /origin -type f -name "*.tif" -exec bash -c 
      'd="$(dirname $1)"; d=$d##*/; fn=$1##*/;
      [ -d "/dest/$d" ] && cp "$1" "/dest/$d/$fn"; ' _ ;





      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        find + bash solution:



        find /origin -type f -name "*.tif" -exec bash -c 
        'd="$(dirname $1)"; d=$d##*/; fn=$1##*/;
        [ -d "/dest/$d" ] && cp "$1" "/dest/$d/$fn"; ' _ ;





        share|improve this answer












        find + bash solution:



        find /origin -type f -name "*.tif" -exec bash -c 
        'd="$(dirname $1)"; d=$d##*/; fn=$1##*/;
        [ -d "/dest/$d" ] && cp "$1" "/dest/$d/$fn"; ' _ ;






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 22 '17 at 13:03









        RomanPerekhrest

        22.4k12145




        22.4k12145






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f412494%2fcopy-a-file-to-a-folder-which-has-the-same-name-as-the-original%23new-answer', 'question_page');

            );

            Post as a guest













































































            bwf4Q5DiBrO9qjUYcFOKARh2JRRAVMly,3Mg2SzNlXHYQdsJefxrE,S mDHWss,lID 7Fyy,0a3KODx HxoEelKDTQ3vLhe
            C,dK jlZp2S877q ei hp 0y2,Aq 4OVG20,8WqOXPrNE,6OYfK FmIa UjASRDFA414o8,1BoCcKC

            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            How many registers does an x86_64 CPU actually have?

            Displaying single band from multi-band raster using QGIS