If you want to copy the set of files to multiple folders, hold down the CONTROL key while dragging and dropping the file(s). This ensures that the files in the drop stack are not removed once the copy process has completed. This makes it easy to copy the same set of files (from different folders) to multiple locations.
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.
To do this, click and hold your left mouse button on the top-left portion of where you want to start highlighting. Next, drag the box until the last file or folder is highlighted. Once the files are selected, they can be copied, cut, or dragged to another window to move them.
In a batch file solution
for /R c:\source %%f in (*.xml) do copy %%f x:\destination\
The code works as such;
for each file for
in directory c:\source
and subdirectories /R
that match pattern (\*.xml)
put the file name in variable %%f
, then for each file do
copy file copy %%f
to destination x:\\destination\\
Just tested it here on my Windows XP computer and it worked like a treat for me. But I typed it into command prompt so I used the single %f
variable name version, as described in the linked question above.
Just use the XCOPY command with recursive option
xcopy c:\*.doc k:\mybackup /sy
/s will make it "recursive"
Things like these are why I switched to Powershell. Try it out, it's fun:
Get-ChildItem -Recurse -Include *.doc | % {
Copy-Item $_.FullName -destination x:\destination
}
Brandon, short and sweet. Also flexible.
set dSource=C:\Main directory\sub directory
set dTarget=D:\Documents
set fType=*.doc
for /f "delims=" %%f in ('dir /a-d /b /s "%dSource%\%fType%"') do (
copy /V "%%f" "%dTarget%\" 2>nul
)
Hope this helps.
I would add some checks after the copy (using '||') but i'm not sure how "copy /v" reacts when it encounters an error.
you may want to try this:
copy /V "%%f" "%dTarget%\" 2>nul|| echo En error occured copying "%%F".&& exit /b 1
As the copy line. let me know if you get something out of it (in no position to test a copy failure atm..)
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