在批处理文件中分割字符串 [英] Split string in batch file
本文介绍了在批处理文件中分割字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚开始使用批处理文件,所以有人可以帮我拆分从文件中获取的字符串.
我正在使用%USERPROFILE%
来获取我的字符串.
字符串是:"C:\Users\nicholas"
我想保留C:\ part
,但要删除\Users\nicholas
部分.
I am new to using batch files so could someone please help me split a string i am getting from a file.
I am using %USERPROFILE%
to get my string.
The string is: "C:\Users\nicholas"
I would like to keep the C:\ part
, but get rid of the \Users\nicholas
part.
推荐答案
for /f "tokens=2 delims=\" %A in ('set userprofile') do echo %A\
查看/?
也
echo %userprofile:~0,3%
这篇关于在批处理文件中分割字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文