cp matching files in CLI on OSX with path slightly modified
I am trying to find a command that finds and copies files with a given name to a another folder but with a slightly different path.
For e.g. there are 4 copies of PNG files named ic_arrow.png
app/src/main/res/drawable-xhdpi/ic_arrow.png
app/src/main/res/drawable-xxhdpi/ic_arrow.png
app/src/main/res/drawable-hdpi/ic_arrow.png
app/src/main/res/drawable-mdpi/ic_arrow.png
and I would like to copy this to
feature/name1/src/main/res/drawable-xhdpi/ic_arrow.png
feature/name1/src/main/res/drawable-xxhdpi/ic_arrow.png
feature/name1/src/main/res/drawable-hdpi/ic_arrow.png
feature/name1/src/main/res/drawable-mdpi/ic_arrow.png
i.e. the right dpi version of the found file gets copied to the right dpi version of the target directory
does anyone know how I can do this with the find command or a script etc?
TIA
linux macos command-line file-transfer
add a comment |
I am trying to find a command that finds and copies files with a given name to a another folder but with a slightly different path.
For e.g. there are 4 copies of PNG files named ic_arrow.png
app/src/main/res/drawable-xhdpi/ic_arrow.png
app/src/main/res/drawable-xxhdpi/ic_arrow.png
app/src/main/res/drawable-hdpi/ic_arrow.png
app/src/main/res/drawable-mdpi/ic_arrow.png
and I would like to copy this to
feature/name1/src/main/res/drawable-xhdpi/ic_arrow.png
feature/name1/src/main/res/drawable-xxhdpi/ic_arrow.png
feature/name1/src/main/res/drawable-hdpi/ic_arrow.png
feature/name1/src/main/res/drawable-mdpi/ic_arrow.png
i.e. the right dpi version of the found file gets copied to the right dpi version of the target directory
does anyone know how I can do this with the find command or a script etc?
TIA
linux macos command-line file-transfer
add a comment |
I am trying to find a command that finds and copies files with a given name to a another folder but with a slightly different path.
For e.g. there are 4 copies of PNG files named ic_arrow.png
app/src/main/res/drawable-xhdpi/ic_arrow.png
app/src/main/res/drawable-xxhdpi/ic_arrow.png
app/src/main/res/drawable-hdpi/ic_arrow.png
app/src/main/res/drawable-mdpi/ic_arrow.png
and I would like to copy this to
feature/name1/src/main/res/drawable-xhdpi/ic_arrow.png
feature/name1/src/main/res/drawable-xxhdpi/ic_arrow.png
feature/name1/src/main/res/drawable-hdpi/ic_arrow.png
feature/name1/src/main/res/drawable-mdpi/ic_arrow.png
i.e. the right dpi version of the found file gets copied to the right dpi version of the target directory
does anyone know how I can do this with the find command or a script etc?
TIA
linux macos command-line file-transfer
I am trying to find a command that finds and copies files with a given name to a another folder but with a slightly different path.
For e.g. there are 4 copies of PNG files named ic_arrow.png
app/src/main/res/drawable-xhdpi/ic_arrow.png
app/src/main/res/drawable-xxhdpi/ic_arrow.png
app/src/main/res/drawable-hdpi/ic_arrow.png
app/src/main/res/drawable-mdpi/ic_arrow.png
and I would like to copy this to
feature/name1/src/main/res/drawable-xhdpi/ic_arrow.png
feature/name1/src/main/res/drawable-xxhdpi/ic_arrow.png
feature/name1/src/main/res/drawable-hdpi/ic_arrow.png
feature/name1/src/main/res/drawable-mdpi/ic_arrow.png
i.e. the right dpi version of the found file gets copied to the right dpi version of the target directory
does anyone know how I can do this with the find command or a script etc?
TIA
linux macos command-line file-transfer
linux macos command-line file-transfer
asked Dec 22 '18 at 3:17
BootstrapperBootstrapper
118114
118114
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The rsync way:
rsync -avh --include="*/" --include="*.png" --exclude="*" app/ feature/name1/
Testing it:
mkdir -p app/src/main/res/drawable-xhdpi/ app/src/main/res/drawable-xxhdpi/ app/src/main/res/drawable-hdpi/ app/src/main/res/drawable-mdpi/
touch app/src/main/res/drawable-xhdpi/ic_arrow.png app/src/main/res/drawable-xxhdpi/ic_arrow.png app/src/main/res/drawable-hdpi/ic_arrow.png app/src/main/res/drawable-mdpi/ic_arrow.png
mkdir -p feature/name1/src/main/res/drawable-xhdpi/ feature/name1/src/main/res/drawable-xxhdpi/ feature/name1/src/main/res/drawable-hdpi/ feature/name1/src/main/res/drawable-mdpi/
tree app
app/
└── src
└── main
└── res
├── drawable-hdpi
│ └── ic_arrow.png
├── drawable-mdpi
│ └── ic_arrow.png
├── drawable-xhdpi
│ └── ic_arrow.png
└── drawable-xxhdpi
└── ic_arrow.png
tree feature
feature/
└── name1
└── src
└── main
└── res
├── drawable-hdpi
├── drawable-mdpi
├── drawable-xhdpi
└── drawable-xxhdpi
rsync command
rsync -avh --include="*/" --include="*.png" --exclude="*" app/ feature/name1/
Final result (tree feature)
feature/
└── name1
└── src
└── main
└── res
├── drawable-hdpi
│ └── ic_arrow.png
├── drawable-mdpi
│ └── ic_arrow.png
├── drawable-xhdpi
│ └── ic_arrow.png
└── drawable-xxhdpi
└── ic_arrow.png
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1386847%2fcp-matching-files-in-cli-on-osx-with-path-slightly-modified%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The rsync way:
rsync -avh --include="*/" --include="*.png" --exclude="*" app/ feature/name1/
Testing it:
mkdir -p app/src/main/res/drawable-xhdpi/ app/src/main/res/drawable-xxhdpi/ app/src/main/res/drawable-hdpi/ app/src/main/res/drawable-mdpi/
touch app/src/main/res/drawable-xhdpi/ic_arrow.png app/src/main/res/drawable-xxhdpi/ic_arrow.png app/src/main/res/drawable-hdpi/ic_arrow.png app/src/main/res/drawable-mdpi/ic_arrow.png
mkdir -p feature/name1/src/main/res/drawable-xhdpi/ feature/name1/src/main/res/drawable-xxhdpi/ feature/name1/src/main/res/drawable-hdpi/ feature/name1/src/main/res/drawable-mdpi/
tree app
app/
└── src
└── main
└── res
├── drawable-hdpi
│ └── ic_arrow.png
├── drawable-mdpi
│ └── ic_arrow.png
├── drawable-xhdpi
│ └── ic_arrow.png
└── drawable-xxhdpi
└── ic_arrow.png
tree feature
feature/
└── name1
└── src
└── main
└── res
├── drawable-hdpi
├── drawable-mdpi
├── drawable-xhdpi
└── drawable-xxhdpi
rsync command
rsync -avh --include="*/" --include="*.png" --exclude="*" app/ feature/name1/
Final result (tree feature)
feature/
└── name1
└── src
└── main
└── res
├── drawable-hdpi
│ └── ic_arrow.png
├── drawable-mdpi
│ └── ic_arrow.png
├── drawable-xhdpi
│ └── ic_arrow.png
└── drawable-xxhdpi
└── ic_arrow.png
add a comment |
The rsync way:
rsync -avh --include="*/" --include="*.png" --exclude="*" app/ feature/name1/
Testing it:
mkdir -p app/src/main/res/drawable-xhdpi/ app/src/main/res/drawable-xxhdpi/ app/src/main/res/drawable-hdpi/ app/src/main/res/drawable-mdpi/
touch app/src/main/res/drawable-xhdpi/ic_arrow.png app/src/main/res/drawable-xxhdpi/ic_arrow.png app/src/main/res/drawable-hdpi/ic_arrow.png app/src/main/res/drawable-mdpi/ic_arrow.png
mkdir -p feature/name1/src/main/res/drawable-xhdpi/ feature/name1/src/main/res/drawable-xxhdpi/ feature/name1/src/main/res/drawable-hdpi/ feature/name1/src/main/res/drawable-mdpi/
tree app
app/
└── src
└── main
└── res
├── drawable-hdpi
│ └── ic_arrow.png
├── drawable-mdpi
│ └── ic_arrow.png
├── drawable-xhdpi
│ └── ic_arrow.png
└── drawable-xxhdpi
└── ic_arrow.png
tree feature
feature/
└── name1
└── src
└── main
└── res
├── drawable-hdpi
├── drawable-mdpi
├── drawable-xhdpi
└── drawable-xxhdpi
rsync command
rsync -avh --include="*/" --include="*.png" --exclude="*" app/ feature/name1/
Final result (tree feature)
feature/
└── name1
└── src
└── main
└── res
├── drawable-hdpi
│ └── ic_arrow.png
├── drawable-mdpi
│ └── ic_arrow.png
├── drawable-xhdpi
│ └── ic_arrow.png
└── drawable-xxhdpi
└── ic_arrow.png
add a comment |
The rsync way:
rsync -avh --include="*/" --include="*.png" --exclude="*" app/ feature/name1/
Testing it:
mkdir -p app/src/main/res/drawable-xhdpi/ app/src/main/res/drawable-xxhdpi/ app/src/main/res/drawable-hdpi/ app/src/main/res/drawable-mdpi/
touch app/src/main/res/drawable-xhdpi/ic_arrow.png app/src/main/res/drawable-xxhdpi/ic_arrow.png app/src/main/res/drawable-hdpi/ic_arrow.png app/src/main/res/drawable-mdpi/ic_arrow.png
mkdir -p feature/name1/src/main/res/drawable-xhdpi/ feature/name1/src/main/res/drawable-xxhdpi/ feature/name1/src/main/res/drawable-hdpi/ feature/name1/src/main/res/drawable-mdpi/
tree app
app/
└── src
└── main
└── res
├── drawable-hdpi
│ └── ic_arrow.png
├── drawable-mdpi
│ └── ic_arrow.png
├── drawable-xhdpi
│ └── ic_arrow.png
└── drawable-xxhdpi
└── ic_arrow.png
tree feature
feature/
└── name1
└── src
└── main
└── res
├── drawable-hdpi
├── drawable-mdpi
├── drawable-xhdpi
└── drawable-xxhdpi
rsync command
rsync -avh --include="*/" --include="*.png" --exclude="*" app/ feature/name1/
Final result (tree feature)
feature/
└── name1
└── src
└── main
└── res
├── drawable-hdpi
│ └── ic_arrow.png
├── drawable-mdpi
│ └── ic_arrow.png
├── drawable-xhdpi
│ └── ic_arrow.png
└── drawable-xxhdpi
└── ic_arrow.png
The rsync way:
rsync -avh --include="*/" --include="*.png" --exclude="*" app/ feature/name1/
Testing it:
mkdir -p app/src/main/res/drawable-xhdpi/ app/src/main/res/drawable-xxhdpi/ app/src/main/res/drawable-hdpi/ app/src/main/res/drawable-mdpi/
touch app/src/main/res/drawable-xhdpi/ic_arrow.png app/src/main/res/drawable-xxhdpi/ic_arrow.png app/src/main/res/drawable-hdpi/ic_arrow.png app/src/main/res/drawable-mdpi/ic_arrow.png
mkdir -p feature/name1/src/main/res/drawable-xhdpi/ feature/name1/src/main/res/drawable-xxhdpi/ feature/name1/src/main/res/drawable-hdpi/ feature/name1/src/main/res/drawable-mdpi/
tree app
app/
└── src
└── main
└── res
├── drawable-hdpi
│ └── ic_arrow.png
├── drawable-mdpi
│ └── ic_arrow.png
├── drawable-xhdpi
│ └── ic_arrow.png
└── drawable-xxhdpi
└── ic_arrow.png
tree feature
feature/
└── name1
└── src
└── main
└── res
├── drawable-hdpi
├── drawable-mdpi
├── drawable-xhdpi
└── drawable-xxhdpi
rsync command
rsync -avh --include="*/" --include="*.png" --exclude="*" app/ feature/name1/
Final result (tree feature)
feature/
└── name1
└── src
└── main
└── res
├── drawable-hdpi
│ └── ic_arrow.png
├── drawable-mdpi
│ └── ic_arrow.png
├── drawable-xhdpi
│ └── ic_arrow.png
└── drawable-xxhdpi
└── ic_arrow.png
answered Dec 22 '18 at 3:59
YoricYoric
3096
3096
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1386847%2fcp-matching-files-in-cli-on-osx-with-path-slightly-modified%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
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