1

I wrote a simple .bat file that appends the string "somethingnew" infront of .txt files:

for %%x in (*.txt) do ren "%%x" "somethingnew%%~nx"

But when I run it from the command prompt (or when I double click it) it does nothing.

I found this post but there is no item called "UserChoice" in the registry and I checked that the .bat association is correct.

Thanks.

EDIT: Also, I've noticed that when I double click the file, the command prompt opens for a split second and then closes, and when I try to run the file through the command prompt, it runs but does nothing.

1 Answers1

1

I just tried your batch script. It works, but it doesn't output anything showing it's working. If you want confirmation it did something, add "pause" on another line. Also, it renamed my txt files without adding .txt to the end of the filename. Here's your updated code that should address both issues:

for %%x in (*.txt) do ren "%%x" "somethingnew%%~nx.txt"
pause
Salocor
  • 737