How to convert the value of %USERNAME% to lowercase within a Windows batch script?

后端 未结 9 587
暗喜
暗喜 2020-12-09 17:10

I\'m automating some source control software functionality using a dot bat script but given that our svn repos are hosted in a *NIX box, I\'m facing the eternal case problem

9条回答
  •  时光取名叫无心
    2020-12-09 17:38

    In my batch file I'm doing a comparsion between %USERNAME% and a CSV file.

    The program would not work if user was logged in UperCase username.

    Ex:
    Login : GB2NOGU // Won't work
    Login : gb2nogu // Works

    Here I could solve my problem doing a insensitive comparison.

    if /i %USERNAME%==gb2nogu (
         // Code here
    )
    

    The parameter /i tells the cmd to do a insensitive case comparison, so it'll ignore the difference between lowercase and uppercase letters.

提交回复
热议问题