So I'm using this command to copy only txt files from a certain directory to another directory
for /R c:\source %%f in (*.xml) do copy %%f x:\destination\
But it only copies over the text files without a space in the name, so it copies test.txt but not test 2.txt. How do I make it so it copies txt files with spaces?
To copy the files with the specific extension, you need to use the Get-ChildItem command. Through the Get-ChildItem you first need to retrieve the files with the specific extension(s) and then you need to pipeline Copy-Item command.
Highlight the files you want to copy. Press the keyboard shortcut Command + C . Move to the location you want to move the files and press Command + V to copy the files.
Xcopy has no built-in functionality to move files and folders from the source to the destination. But, as a workaround, you can create a script that would Xcopy the files first and then delete the files from the source. The code below will copy the files to the destination.
Add quotes just around the variable after the copy command:
for /R c:\source %%f in (*.xml) do copy "%%f" x:\destination\
What's wrong with
copy c:\source\*.xml x:\destination\ >nul
[Edit] Oh I see, you want to copy all the files in all directories recursively, but without copying the directory structure. Nevermind, then.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With