如果我有类似的东西
set value = c:\\some\\path
我想将其转换为
c:\some\path
。
我该怎么做呢?
答案1
从这里您可以使用字符串替换。
@echo off
set value=c:\\some\\path
echo %value%
set new_value=%value:\\=\%
echo %new_value%
输出
c:\\some\\path
c:\some\path
(是的,我也刚刚学会了这个技巧)
该链接还具有
Align Right Align text to the right i.e. to improve readability of number columns.
Left String Extract characters from the beginning of a string.
Map and Lookup Use Key-Value pair list to lookup and translate values.
Mid String Extract a Substring by Position.
Remove Remove a substring using string substitution.
Remove both Ends Remove the first and the last character of a string.
Remove Spaces Remove all spaces in a string via substitution.
Replace Replace a substring using string substitution.
Right String Extract characters from the end of a string.
Split String Split a String, Extract Substrings by Delimiters.
String Concatenation Add one string to another string.
Trim Left Trim spaces from the beginning of a string via "FOR" command.
Trim Quotes Remove surrounding quotes via FOR command.
Trim Right Trim spaces from the end of a string via substitution.
Trim Right Trim spaces from the end of a string via "FOR" command.