1.

Solve : Batch Variable require for copying....?

Answer»

I NEED a Variable for DOS. I want to copy Links.txt to all drives in a time.
copy links.txt %alldrives%

I don't know what should type in place of %alldrives% for every drive copy.
What value did you plan on %alldrives% having? It might be easier to do each drive separately in a loop.

Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition"') do (
copy links.txt %%i:\
)

You can fixup the paths as necessary.

Good luck. Quote from: Sidewinder on December 20, 2008, 12:55:48 PM

What value did you plan on %alldrives% having? It might be easier to do each drive separately in a loop.

Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition"') do (
copy links.txt %%i:\
)

You can fixup the paths as necessary.

Good luck.

I saved all in a batch.
also changed my paths like this....
Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "G:") do (
copy links.txt %%i:\
)
But not working...Sidewinder, a batch file like that is excessively strong magic for a novice, I think!

Quote from: afzaldir on December 20, 2008, 11:15:59 PM

I saved all in a batch.
also changed my paths like this....
Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition" ' ) do (

copy links.txt "%%i:\Path to Folder\Folder"
REM FIX THIS ^^^^^^ TO INCLUDE FOLDER FOR FILE TO GO TO
)
But not working...

You "fixed" the wrong path.Not Understand Yet.
also not working....
Please explain with code. [+path]
I want copy links.txt G: and D:
Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition"') do (
copy links.txt %%i:\
)

that will copy the file links.txt to each visible logical drive. If you only wanted to copy to G: and D:

Code: [Select]for %%p in (D G) do copy links.txt %%p:
Or why not just do

copy links.txt d:\
copy links.txt g:\

?

Oh come on now, that's too easy This work good:
Code: [Select]for %%p in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do copy Links.txt %%p:
But first Code is not working yet.....
Thanks u all and special BC_Programmer


Discussion

No Comment Found