1.

Solve : Copy from subdirectories.?

Answer»

Hi All!!

I would like copy *.txt file from all subdirectories.


Any Idea???

Thanks,
JayJayanand, you don't give enough information!!!

From where?
To where?

As i have stated

From : All subdirectories
To : Specific folder in C:/ drive

Thanks,
JayDo you mean

from all subdirectories of root directory on C drive (ie all directories under C:\)
to a specific directory on the C drive or elsewhere?
yes!let us assume you want the txt files to end up in the directory c:\target directory

Code: [Select]@echo off
for /F "delims==" %%a in ('dir c:\*.txt /s /b') do (
echo copying %%a
copy "%%a" "C:\target directory"
)




Thanks !it's working perfectly.

Thanks,
JayQuote from: Jayanand on May 14, 2007, 05:17:16 AM

Thanks !it's working perfectly.

Thanks,
Jay

You edited your POST while I was answering the questions.

1. It is common practice in laying out code to indent structures such as loops, blocks, etc. This makes such elements of structure clearer. It is purely a matter of preference. It helps to SEE that you have matching numbers of start and finish structure statements, ESPECIALLY when structures are nested.

EG in BASIC, but also in many other situations.

Code: [Select]
FOR J = 1 to 10
PRINT J
PRINT J+6
NEXT J

IF X=10 THEN
PRINT X
END IF

IF A>10 THEN
IF B = 6 THEN
FOR X = B TO A
PRINT X
NEXT X
END IF
END IF





2. "delims==" tells FOR that the token delimiters are the BEGINNING and end of the each line (IE do not slice at spaces, commas, etc)

"delims=," would result in dissection of lines at commas.


Thanks for making easiest.

Thanks,
Jay


Discussion

No Comment Found