Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Dear people's i need your help!
first of all im sorry about my poor english, hope you understand me..
i wrote a code that finds a file inside a local drive or inside a FOLDORxcopy X:\ "%TEMP%" /H /L /S /Y | find "FileName"
As you can see, "X" presenting the local drive.For example:
If i wants to find the "win.ini" file at drive "C"
ill do like so:xcopy c:\ "%TEMP%" /H /L /S /Y | find "win.ini*"
and ill get the next thing:C:\Windows\win.ini
and its working! BUT..
i can't enter the adress that i got to a variable.
lets say that i want to enter the "adress" of the file win.ini to a variable "X" how can i do it??

Your command,
xcopy X:\ "%TEMP%" /H /L /S /Y | find "FileName"may find multiple files called "FileName" in different folders. You need to decide which one of those you need to copy to a variable. The following set variable FPATH to the last file found:
for /f "delims=" %%a in ('xcopy X:\ "%TEMP%" /H /L /S /Y ^| find "FileName"') do ( set FPATH=%%a )
By the way, instead of using "find", the following command is a bit faster:xcopy "X:\FileName" "%TEMP%" /H /L /S /YAlso, the following command is even faster still:
dir /s /b "X:\FileName"

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |