Script to automate copy files with a pattern over network
I am trying to automate some tasks... I have to do some development work on one machine and other parts on another machine, with communication through a network share.
I would like to copy certain files, not the entire directories - which may contain lots of additional build items, some large.
Something like
set source="C:UsersmeDocumentssourcefolder"
set dest="\SHAREFOLDERmedestfolder"
xcopy %source%+"*.cpp" %dest%
How can I do a command like this ? copy all files with a given pattern (like *.cpp) from source to destination ?
Also - can that be done recursively - for all the folders inside source ?
Edit:
Trying
xcopy "C:UsersmeDocumentssourcefolder*.cpp" "\SHAREFOLDERmedestfolder"
(first try did not work because I did not know I should make a bat file. Thank you Saggio.)
Still... for best results, for a complex directory structure I would like to be able to use variables and perhaps copy recursively - there are many directories I have to copy over.
Also, the patterns I want to copy are something like "all files with extension .cpp, except those that start with moc_" or ""all files with extension .h, except those that start with ui_"
I could copy then delete the ones hat I don't want I guess... But is there a better way ?
windows shell network-shares file-transfer
|
show 4 more comments
I am trying to automate some tasks... I have to do some development work on one machine and other parts on another machine, with communication through a network share.
I would like to copy certain files, not the entire directories - which may contain lots of additional build items, some large.
Something like
set source="C:UsersmeDocumentssourcefolder"
set dest="\SHAREFOLDERmedestfolder"
xcopy %source%+"*.cpp" %dest%
How can I do a command like this ? copy all files with a given pattern (like *.cpp) from source to destination ?
Also - can that be done recursively - for all the folders inside source ?
Edit:
Trying
xcopy "C:UsersmeDocumentssourcefolder*.cpp" "\SHAREFOLDERmedestfolder"
(first try did not work because I did not know I should make a bat file. Thank you Saggio.)
Still... for best results, for a complex directory structure I would like to be able to use variables and perhaps copy recursively - there are many directories I have to copy over.
Also, the patterns I want to copy are something like "all files with extension .cpp, except those that start with moc_" or ""all files with extension .h, except those that start with ui_"
I could copy then delete the ones hat I don't want I guess... But is there a better way ?
windows shell network-shares file-transfer
couldn't you just doxcopy %source%*.cpp %dest%
?
– Saggio
Nov 4 '14 at 22:22
I am trying... so far I get an error about compatibility... and when trying to use the "Compatibility" tab to run, no error but also nothing happens.
– Thalia
Nov 4 '14 at 22:25
What errors are you seeing specifically?
– Richard Turner
Nov 4 '14 at 22:25
2
why are you creating an executable file? It looks likemove.exe
is x86 and you're in an x64 environment. Since it's working running it straight from the cmd line, perhaps just create a a*.bat
file script instead of a full fledged executable?
– Saggio
Nov 4 '14 at 22:31
1
@Saggio thank you, now I feel ridiculous... I did not know how to create a windows script...
– Thalia
Nov 4 '14 at 22:33
|
show 4 more comments
I am trying to automate some tasks... I have to do some development work on one machine and other parts on another machine, with communication through a network share.
I would like to copy certain files, not the entire directories - which may contain lots of additional build items, some large.
Something like
set source="C:UsersmeDocumentssourcefolder"
set dest="\SHAREFOLDERmedestfolder"
xcopy %source%+"*.cpp" %dest%
How can I do a command like this ? copy all files with a given pattern (like *.cpp) from source to destination ?
Also - can that be done recursively - for all the folders inside source ?
Edit:
Trying
xcopy "C:UsersmeDocumentssourcefolder*.cpp" "\SHAREFOLDERmedestfolder"
(first try did not work because I did not know I should make a bat file. Thank you Saggio.)
Still... for best results, for a complex directory structure I would like to be able to use variables and perhaps copy recursively - there are many directories I have to copy over.
Also, the patterns I want to copy are something like "all files with extension .cpp, except those that start with moc_" or ""all files with extension .h, except those that start with ui_"
I could copy then delete the ones hat I don't want I guess... But is there a better way ?
windows shell network-shares file-transfer
I am trying to automate some tasks... I have to do some development work on one machine and other parts on another machine, with communication through a network share.
I would like to copy certain files, not the entire directories - which may contain lots of additional build items, some large.
Something like
set source="C:UsersmeDocumentssourcefolder"
set dest="\SHAREFOLDERmedestfolder"
xcopy %source%+"*.cpp" %dest%
How can I do a command like this ? copy all files with a given pattern (like *.cpp) from source to destination ?
Also - can that be done recursively - for all the folders inside source ?
Edit:
Trying
xcopy "C:UsersmeDocumentssourcefolder*.cpp" "\SHAREFOLDERmedestfolder"
(first try did not work because I did not know I should make a bat file. Thank you Saggio.)
Still... for best results, for a complex directory structure I would like to be able to use variables and perhaps copy recursively - there are many directories I have to copy over.
Also, the patterns I want to copy are something like "all files with extension .cpp, except those that start with moc_" or ""all files with extension .h, except those that start with ui_"
I could copy then delete the ones hat I don't want I guess... But is there a better way ?
windows shell network-shares file-transfer
windows shell network-shares file-transfer
edited Nov 4 '14 at 22:42
Thalia
asked Nov 4 '14 at 22:14
ThaliaThalia
29511024
29511024
couldn't you just doxcopy %source%*.cpp %dest%
?
– Saggio
Nov 4 '14 at 22:22
I am trying... so far I get an error about compatibility... and when trying to use the "Compatibility" tab to run, no error but also nothing happens.
– Thalia
Nov 4 '14 at 22:25
What errors are you seeing specifically?
– Richard Turner
Nov 4 '14 at 22:25
2
why are you creating an executable file? It looks likemove.exe
is x86 and you're in an x64 environment. Since it's working running it straight from the cmd line, perhaps just create a a*.bat
file script instead of a full fledged executable?
– Saggio
Nov 4 '14 at 22:31
1
@Saggio thank you, now I feel ridiculous... I did not know how to create a windows script...
– Thalia
Nov 4 '14 at 22:33
|
show 4 more comments
couldn't you just doxcopy %source%*.cpp %dest%
?
– Saggio
Nov 4 '14 at 22:22
I am trying... so far I get an error about compatibility... and when trying to use the "Compatibility" tab to run, no error but also nothing happens.
– Thalia
Nov 4 '14 at 22:25
What errors are you seeing specifically?
– Richard Turner
Nov 4 '14 at 22:25
2
why are you creating an executable file? It looks likemove.exe
is x86 and you're in an x64 environment. Since it's working running it straight from the cmd line, perhaps just create a a*.bat
file script instead of a full fledged executable?
– Saggio
Nov 4 '14 at 22:31
1
@Saggio thank you, now I feel ridiculous... I did not know how to create a windows script...
– Thalia
Nov 4 '14 at 22:33
couldn't you just do
xcopy %source%*.cpp %dest%
?– Saggio
Nov 4 '14 at 22:22
couldn't you just do
xcopy %source%*.cpp %dest%
?– Saggio
Nov 4 '14 at 22:22
I am trying... so far I get an error about compatibility... and when trying to use the "Compatibility" tab to run, no error but also nothing happens.
– Thalia
Nov 4 '14 at 22:25
I am trying... so far I get an error about compatibility... and when trying to use the "Compatibility" tab to run, no error but also nothing happens.
– Thalia
Nov 4 '14 at 22:25
What errors are you seeing specifically?
– Richard Turner
Nov 4 '14 at 22:25
What errors are you seeing specifically?
– Richard Turner
Nov 4 '14 at 22:25
2
2
why are you creating an executable file? It looks like
move.exe
is x86 and you're in an x64 environment. Since it's working running it straight from the cmd line, perhaps just create a a *.bat
file script instead of a full fledged executable?– Saggio
Nov 4 '14 at 22:31
why are you creating an executable file? It looks like
move.exe
is x86 and you're in an x64 environment. Since it's working running it straight from the cmd line, perhaps just create a a *.bat
file script instead of a full fledged executable?– Saggio
Nov 4 '14 at 22:31
1
1
@Saggio thank you, now I feel ridiculous... I did not know how to create a windows script...
– Thalia
Nov 4 '14 at 22:33
@Saggio thank you, now I feel ridiculous... I did not know how to create a windows script...
– Thalia
Nov 4 '14 at 22:33
|
show 4 more comments
1 Answer
1
active
oldest
votes
Did not list you OS and enviroment
If you can use robocopy
it has all the tools you need to do this depending on your details :
robocopy %source% %dest% *.cpp /s
will copy all cpp files from the source to dest
it includes many other options for automating this task depending on exactly what you want. just do a robocopy /? and it will list them. For example, you can do a test robocopy that only shows what it would have done if it had been for real.
/L :: List only - don't copy, timestamp or delete any files.
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%2f835969%2fscript-to-automate-copy-files-with-a-pattern-over-network%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
Did not list you OS and enviroment
If you can use robocopy
it has all the tools you need to do this depending on your details :
robocopy %source% %dest% *.cpp /s
will copy all cpp files from the source to dest
it includes many other options for automating this task depending on exactly what you want. just do a robocopy /? and it will list them. For example, you can do a test robocopy that only shows what it would have done if it had been for real.
/L :: List only - don't copy, timestamp or delete any files.
add a comment |
Did not list you OS and enviroment
If you can use robocopy
it has all the tools you need to do this depending on your details :
robocopy %source% %dest% *.cpp /s
will copy all cpp files from the source to dest
it includes many other options for automating this task depending on exactly what you want. just do a robocopy /? and it will list them. For example, you can do a test robocopy that only shows what it would have done if it had been for real.
/L :: List only - don't copy, timestamp or delete any files.
add a comment |
Did not list you OS and enviroment
If you can use robocopy
it has all the tools you need to do this depending on your details :
robocopy %source% %dest% *.cpp /s
will copy all cpp files from the source to dest
it includes many other options for automating this task depending on exactly what you want. just do a robocopy /? and it will list them. For example, you can do a test robocopy that only shows what it would have done if it had been for real.
/L :: List only - don't copy, timestamp or delete any files.
Did not list you OS and enviroment
If you can use robocopy
it has all the tools you need to do this depending on your details :
robocopy %source% %dest% *.cpp /s
will copy all cpp files from the source to dest
it includes many other options for automating this task depending on exactly what you want. just do a robocopy /? and it will list them. For example, you can do a test robocopy that only shows what it would have done if it had been for real.
/L :: List only - don't copy, timestamp or delete any files.
answered May 24 '16 at 17:21
bvaughnbvaughn
73349
73349
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%2f835969%2fscript-to-automate-copy-files-with-a-pattern-over-network%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
couldn't you just do
xcopy %source%*.cpp %dest%
?– Saggio
Nov 4 '14 at 22:22
I am trying... so far I get an error about compatibility... and when trying to use the "Compatibility" tab to run, no error but also nothing happens.
– Thalia
Nov 4 '14 at 22:25
What errors are you seeing specifically?
– Richard Turner
Nov 4 '14 at 22:25
2
why are you creating an executable file? It looks like
move.exe
is x86 and you're in an x64 environment. Since it's working running it straight from the cmd line, perhaps just create a a*.bat
file script instead of a full fledged executable?– Saggio
Nov 4 '14 at 22:31
1
@Saggio thank you, now I feel ridiculous... I did not know how to create a windows script...
– Thalia
Nov 4 '14 at 22:33