How do I perform string operations on variables in a for loop?

前端 未结 5 802
遇见更好的自我
遇见更好的自我 2021-02-06 06:57

This sounds dumb, but I can\'t get it to work. I think i just dont\' understand the difference between %%v, %v% and %v

Here\'s what I\'m trying to do:

5条回答
  •  长发绾君心
    2021-02-06 07:43

    For people who found this thread looking for how to actually perform string operations on for-loop variables (uses delayed expansion):

    setlocal enabledelayedexpansion
    
    ...
    
    ::Replace "12345" with "abcde"
    for %%i in (*.txt) do (
        set temp=%%i
        echo !temp:12345=abcde!
    )
    

提交回复
热议问题