Copy a file to a folder, which has the same name as the original
Clash 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!
ubuntu file-copy
add a comment |Â
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!
ubuntu file-copy
idownvotedbecau.se/noattempt
â Murphy
Dec 22 '17 at 13:03
add a comment |Â
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!
ubuntu file-copy
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!
ubuntu file-copy
asked Dec 22 '17 at 12:24
Adam Gosztolai
30036
30036
idownvotedbecau.se/noattempt
â Murphy
Dec 22 '17 at 13:03
add a comment |Â
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
add a comment |Â
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"; ' _ ;
add a comment |Â
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"; ' _ ;
add a comment |Â
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"; ' _ ;
add a comment |Â
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"; ' _ ;
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"; ' _ ;
answered Dec 22 '17 at 13:03
RomanPerekhrest
22.4k12145
22.4k12145
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
idownvotedbecau.se/noattempt
â Murphy
Dec 22 '17 at 13:03