enter file path to a variable

October 7, 2009 at 18:33:41
Specs: Windows Vista
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 FOLDOR
xcopy 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:

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??

See More: enter file path to a variable

Report •

October 8, 2009 at 04:12:14
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 /Y

Also, the following command is even faster still:

dir /s /b "X:\FileName"

Report •

October 8, 2009 at 07:22:42
Ohhh dude So much tnxxxx!!!!

Report •

Related Solutions

Ask Question