|
Answer» I want to find the path of a file
for eg: if the file is aaa.txt I can able to find the path as c:\test\aaa.txt But the way I want is c:\test alone... can anyone help me in this regardCode: [Select]@echo off for /f %%I in ('dir "C:\aaa.txt" /s /b) do @echo %%~dpI echo. pauseUse the above code in a batch file.
I THINK that should work (BTW, this thread should probably be under Microsoft DOS, but...).
This batch returns the file path and drive letter only, and then pauses.
I know that it needs some work (i.e. to find the file without having to INPUT the name), but it'll get done soon.
EDIT: FIXED!thank u very much dude...
if suppose iam having the filename in one variable like set filename = aaa.txt and the path in one variable like filepath = c:\test\aaa.txt
if it is in this scenario how should i get thatOh. I get you.
Code: [Select]@echo off for %%I in (C:\test\aaa.txt) do ( set FPATH=%%~dpI set FNAME=%%~nxI goto echo )
:echo echo Filepath is %FPATH% echo Filename is %FNAME% echo. echo. pause From that, you can use %FPATH% and %FNAME% wherever you want in your code.Thanks a lot dude....thank u very much No PROBLEM! Glad to see that your question is ANSWERED.
|