to open file in external hard drive

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Kalop
Posts: 14
Joined: 21 Nov 2011 21:31

to open file in external hard drive

#1 Post by Kalop » 29 Nov 2011 03:04

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.

:?: :?: :?:

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: to open file in external hard drive

#2 Post by orange_batch » 29 Nov 2011 03:32

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

Kalop
Posts: 14
Joined: 21 Nov 2011 21:31

Re: to open file in external hard drive

#3 Post by Kalop » 30 Nov 2011 04:50

Hi,
Thank you very much.
It is exactly what I need.

:P

Post Reply