1

I have seen the other posts in this site like Renaming a file after IF EXIST check within ++ FOR loop in a Windows batch file?

But since i am very new to writing batch am not able to understand those links.

I have an existing batch which works fine if the file exist. But if it does not then throws error. I want my existing batch to be modified in such a way that if the required file does not exist it will simply skip, with out throwing any error.In my case the file name is constant.

FOR /R "S:\SOURCES\TATW\ANALYZED\TRANSFER_AGENCY_TA_WEBSERVICES" %%f IN (WEb.config) DO REN "%%f" Web.config.xml
Community
  • 1
  • 1
koushik
  • 99
  • 1
  • 9
  • 3
    Firstly, you probably ought to `ren "%%~ff" newname` to expand `%%f` to its fully qualified drive:\path\to\filename. To answer your question, you could just replace `REN` with `2>NUL REN` to suppress errors. Otherwise, I think what you're looking for is `for... do if exist "%%~ff" ren "%%~ff" Web.config.xml` – rojo Apr 06 '16 at 12:04
  • A big thank you... It solved my problem....@rojo – koushik Apr 06 '16 at 13:45

0 Answers0