scripting - Split own filename and assign specific parts to variables in a batch script -


thanks in advance offered.

i have batch file name want use parts , assign them variables. using /f delims able have rename file different scheme need. se here have:

-current filename: whid-prt-mfp-3, north east office.bat

set getname=%~n0  /f "tokens=1 delims=-" %%g in ("%getname%") (set siteid=%%g)  /f "tokens=1 delims=," %%e in ("%getname%") (set name=%%e)   set printername=%name%  set servername=server-%siteid%-01 

ok, seems work ok , im able parts need file name , assign them variable %name%=whid-prt-mfp-3 , %siteid%=whid

now dilema need file name be: north east office, whid-prt-mfp-3.bat i've been trying entire line behind comma(whid-prt-mfp-3) variable , first item in dashes(whid) variable, same example above, cant figure out. used several names not example shown have shorter or longer names both parts, say: whid-prt-1, office 1

any ideas welcome.

thanks

north east office, whid-prt-mfp-3.bat:

set getname=%~n0  rem split @ comma /f "tokens=2 delims=," %%e in ("%getname%") (      rem trim space after comma     /f "tokens=*" %%s in ("%%e") set name=%%s      rem word before hyphen , strip leading space     /f "tokens=1 delims=- " %%s in ("%%e") set siteid=%%s )  set printername=%name% set servername=server-%siteid%-01 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -