copy batch command

February 8, 2011 at 23:50:15
Specs: Windows XP
i want to copy all the doc files that start with "k" from folder called DOCUMENTS in my c:\ to a destination folder . The problem is that i also want it copy the K's files from the subfolders under it without creating folder tree in tge destination (thats why i dont use XCOPY)

I tried the command -
for /r "c:\documents" /d %%a in (.) do @ copy /y "%%a\k*.doc" c:\destination

it COPY the files to the destination but (!!!!) WITHOUT DATA - i copy file from source that is 24K and i get it in the destination in size 1K.

what can be the problem ?

Thanks Ami

See More: copy batch command

Report •

February 9, 2011 at 00:16:00
I would suggest using the ~F modifier:

copy /y "%%~Fa\k*.doc" c:\destination

Report •

February 9, 2011 at 00:57:02
it didnt work :-(

Report •

February 9, 2011 at 03:52:59
I'm not sure what's happening.......

Perhaps a different approach may help.

for /f %%a in ('dir /s/b/a-d "c:\documents\k*.txt" ') do echo copy /y "%%a" "c:\destination"

Report •

Related Solutions

February 9, 2011 at 04:31:21
@echo off & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b/s/a-d "c:\DOCUMENTS\k*.doc"') do (
copy."%%a" dest

Life is too important to be taken seriously.


Report •

Ask Question