-2

There is a single line code

cmd /v/c "for %%i in ("%CD%\*.txt") do @(call rename "%%i" "%%~ni1.txt" & call echo 1)"
pause

How to inject line break to get something like this?

cmd /v/c "for %%i in ("%CD%\*.txt") do @(call rename "%%i" "%%~ni1.txt" & ^
call echo 1)"
pause

If it is impossible, just write that this is impossible.

Compo
  • 30,301
  • 4
  • 20
  • 32
qweqwe1
  • 13
  • 1
  • It would help if you were to explain what you're trying to achieve. Could you please [edit your question](https://stackoverflow.com/posts/59356403/edit) to include the expected output and perhaps a few example filenames, to run the code against. – Compo Dec 16 '19 at 12:18
  • 1
    When you're on it, please also explain why you are using `cmd /v/c` and `call`. – Stephan Dec 16 '19 at 12:19
  • 1
    Not knowing what you are trying to achieve or what is the purpose of all this, the line continuation you are trying to do (`^`) cannot work, because it appears in between `""`, so the caret `^` is not recognised as a special character; you could try to remove the outer-most pair of `""` or to escape them like `^"`... – aschipfl Dec 16 '19 at 12:26
  • jeb, this is not dublicate, ^ is not working, man – qweqwe1 Dec 16 '19 at 13:07
  • @qweqwe1, follow the advice in the comments and edit your question with sufficient information for us to determine that the linked question does not provide the solution to your issue. If you do not do that your question will remain closed. – Compo Dec 16 '19 at 13:25
  • Compo, all is described in the topic, no more, no less. – qweqwe1 Dec 16 '19 at 14:05
  • it's absolutely irrelevant to `for` or `do`. It's just that [`^` doesn't work as an escape character inside quotes](https://stackoverflow.com/a/4095133/995714) – phuclv Dec 18 '19 at 23:26

1 Answers1

0

Although I have no idea what you want to accomplish with cmd /v /c and the call commands:

cmd /v/c ^"for %%i in ("%CD%\*.txt") do @(call rename "%%i" "%%~ni1.txt" & ^
call echo 1

Note: your ^ didn't work, because it was inside a quoted string. By escaping the opening quote, you can overcome this limitation.
Be aware that the line break breaks context, so omit the closing " and the closing ) in the second line (as they are both disconnected from their opening counterpart and so do nothing special any more).

Stephan
  • 47,723
  • 10
  • 50
  • 81