Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want batch file to check if exist in the main drive
for example
set /p test=type the file:
if %test%== %drivename% goto fin
if %test%== %drivename% goto end

:fin
echo the file is in the main partition
pause
exit
:end
echo the file is not in the main partition
pause
exit
Posted
Comments
xxv2012 22-Jan-14 13:47pm    
replace this %drivename% to %homedrive% and replace this if %test%== %drivename% goto end to if not %test%== %drivename% goto end

1 solution

Could something like this do what you expect?
<br />
@echo off<br />
set /P test=type the file:<br />
<br />
call :check_main "%test%"<br />
pause<br />
goto :EOF<br />
<br />
:check_main<br />
if "%~d1" == "%HOMEDRIVE%" (<br />
  echo the file is in the main partition<br />
) else (<br />
  echo the file is not in the main partition<br />
)<br />
goto :EOF<br />


The snippet above checks, whether a gile with a give name is located on the %HOMEDRIVE%
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900