|
Answer» So with my batch file, you are able to drag two files into it. But, I manually have to decide which file is which ( echo If you asm is first, type 1. If it is second, type 2. echo. echo %1 echo %2 echo. echo ------------------ set choice= set /p choice= if not '%choice%'=='' set choice=%choice:~0,1% if '%choice%'=='1' goto one if '%choice%'=='2' goto two echo "%choice%" is not valid please try again )
I was wondering if there was a way to compare extensions and execute accordingly. example: ( if [%1]==[*.asm] go to one )
please note that the above example does not work The extension part of a file name, if present, including the dot, is extracted USING the ~xV variable modifier thus... (V=variable, in this case it is %~x1)
if [%~x1]==[.asm] go to one
If %1 = S:\test\batch\extest\tryme.bat, then...
~d1 drive letter and colon S: ~p1 path and folder \test\batch\extest\ ~n1 name part of filename tryme ~x1 extension .bat
You can join them:
e.g. ~dpnx1 is S:\test\batch\extest\tryme.bat
These MODIFIERS also apply to FOR loop variables e.g. %%~nA
type FOR /? at prompt for FULL help
Im a bit baffled. I think.. So from my understanding, i use one of those variables with a numeral?
so to see if %1 is an asm file, I'd do this: ( if [%~x1]==[.asm] goto one ) and to see if %2 is a smc file, I'd do this?: ( if [%~X2]==[.smc] goto two )That is correct, but what are the red parentheses for? to show code >. Code: [Select]if [%~x1]==[.asm] goto one
|