
Re: Using a variable that's part of a filename to open that
I.Love.to.Use.DOS wrote:
I'll want to use a variable when typing into Run field this way:
C PLASTIC
Where typing PLASTIC would open PLASTIC.RTF
typing
C PLASTIC will open PLASTIC.COMMENT.RTF
(1)
; Batch File Name 'PLASTIC.bat'
@echo off
start "D:\Program Files\Cwordpad\CWordPad.exe" "c:\Users\Acer1\Documents\PLASTIC.rtf"
Call this a.bat and then you can type this (including the a)
a plastic
and it will open plastic.rtf
If you type
a b plastic
then it will open plastic.comment.rtf
b can be any character.
and if you change plastic to another word, say steel
a steel
it will open steel.rtf
and if you type
a b steel
then it will open steel.comment.rtf
Code:
@echo off
if "%~2"=="" (start "D:\Program Files\Cwordpad\CWordPad.exe" "c:\Users\Acer1\Documents\%~1.rtf")
if not "%~2"=="" (start "D:\Program Files\Cwordpad\CWordPad.exe" "c:\Users\Acer1\Documents\%~2.comment.rtf"