1

I am using a batch file to view the contents (xml files) of a certain folder. I need to use a batch file for it.

Found this command on internet and it is working perfectly when I type in the command prompt, but when I type it in and save as a batch file, it doesn't give any out put at all. (Basically not running the content)

FOR /R D:\Myfolder %F in (*.*) do rename %~nF.xml %~nf1.xml 

There are no restrictions in the folder either.

1
  • The name of the folder is "Myfolder" in this example.Also it contains only xml files. No folders or other stuff in it. Commented Jul 4, 2013 at 5:17

1 Answer 1

1

Shouldn't have worked from the prompt.

In a batch file, you need to change any % for the metavariable (%F in this case) to %%.

Having said that however, (or, from the prompt, %F and %f) are two different animals. It's virtually the only situation where batch is case-sensitive. Your command attempts to rename files using their NAME only (~nF) so if it was to encounter fred.txt it would attempt to rename Fred.xml to -er, 1.xml (I think, maybe %~nf.xml)

Best to say what you're trying to do. We're reasonably slick at crufting up solutions...

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Peter. I changed it to as you said like this "FOR /R D:\Myfolder %%F in (*.xml) do rename %%~nF.xml %%~nF1.xml" It's working fine.. Many Thanks (y)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.