G
G
Goobert Crypto2020-05-05 15:09:26
cmd/bat
Goobert Crypto, 2020-05-05 15:09:26

How to run this command with bat?

There are multiple files


gd-5.txt
Wddss-5.txt
Hf-66sa-7.txt
...

This command:
spoiler
for /f "tokens=* delims= " %i in ('dir /b "*.txt"') do Set LIST=%i& set LIST | ren "%~fi" "%LIST:-=%"

Renames these files to this form, without a dash (gd5.txt
Wddss5.txt)
But
This command only works through cmd.
How can I make this command work only with the launch of the batch file?))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2020-05-05
@goober-crypto

This is how it will be done:

for /f "tokens=* delims= " %%i in ('dir /b "*.txt"') do Set LIST=%%i& set LIST | ren "%%~fi" "%LIST:-=%"

Only your design in the batch file will not work correctly.
Correct like this:
SetLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%i in ('dir /b "*.txt"') do (Set LIST=%%i & ren "%%~fi" "!LIST:-=!")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question