2011-01-31 110 views
1

我想知道是否有更好的方法重命名兩個文件並在批處理文件中替換名稱。我目前正在使用這種方法。使用批處理文件替換文件名

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 
) 

回答

1

在我看來,方式沒問題,但假的情況是行不通的。
如果文件_http.conf不存在,則嘗試將其重命名爲http.conf。

我將其更改爲

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

...,最後:`德爾temp_httpd.conf`? – 2011-02-01 07:39:53

相關問題