Computing.Net > Forums > Programming > enter file path to a variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

enter file path to a variable

Reply to Message Icon

Name: NuniM
Date: October 7, 2009 at 18:33:41 Pacific
OS: Windows Vista
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: October 8, 2009 at 04:12:14 Pacific
Reply:

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"


1

Response Number 2
Name: NuniM
Date: October 8, 2009 at 07:22:42 Pacific
Reply:

Ohhh dude So much tnxxxx!!!!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: enter file path to a variable

setting an output to a variable in unix www.computing.net/answers/programming/setting-an-output-to-a-variable-in-unix/20293.html

Batch File- Subfolder as a Variable www.computing.net/answers/programming/batch-file-subfolder-as-a-variable/14153.html

Read a txt file to a variable www.computing.net/answers/programming/read-a-txt-file-to-a-variable/16422.html