Page 1 of 1

to open file in external hard drive

Posted: 29 Nov 2011 03:04
by Kalop
How to writhe simple batch file with option:1 to open folder and text file in external hard drive, and if the drive not found, option:2 to close the process.

:?: :?: :?:

Re: to open file in external hard drive

Posted: 29 Nov 2011 03:32
by orange_batch
F = your drive letter.

Code: Select all

if exist "F:\" (explorer "F:\"&notepad "F:\myfile.txt") else exit/b

Or for easier modification...

Code: Select all

set drive=F
if exist "%drive%:\" (explorer "%drive%:\"&notepad "%drive%:\myfile.txt") else exit/b

Re: to open file in external hard drive

Posted: 30 Nov 2011 04:50
by Kalop
Hi,
Thank you very much.
It is exactly what I need.

:P