开发者

Alternate file names with a batch file

开发者 https://www.devze.com 2023-02-07 09:46 出处:网络
I would like to know if there i开发者_Python百科s a better way of renaming two files and alternate the names within a batch file. I am currently using this method.

I would like to know if there i开发者_Python百科s a better way of renaming two files and alternate the names within a batch file. I am currently using this method.

ren httpd.conf temp_httpd.conf 
if exist _httpd.conf (
ren _httpd.conf httpd.conf
ren temp_httpd.conf _httpd.conf
)else (
ren _httpd.conf httpd.conf
)


In my opinion the way is ok, but the false-case can't work.
If the file _http.conf doesn't exists, you try to rename it to http.conf.

I would change it to

if exist _httpd.conf (
  ren httpd.conf temp_httpd.conf
  ren _httpd.conf httpd.conf
  ren temp_httpd.conf _httpd.conf
)
0

精彩评论

暂无评论...
验证码 换一张
取 消