2012-12-25 19 views

回答

3

下面的批處理文件就像COPY命令一樣只有一個文件。如果該文件已存在於目標文件夾中,則將括號中的數字添加到新文件以保留這兩個文件。

@echo off 
Rem mycopy sourceFile targetDir 
Set targetName=%~1 
Set i=0 
:nextName 
    If not exist "%~2/%targetName%" goto copy 
    Set /A i+=1 
    Set targetName=%~1 (%i%) 
    Goto nextName 
:copy 
Copy %1 "%~2/%targetName%" 
+0

謝謝@Aacini非常多,您的答案對我有很大的幫助,,祝您好運,更好的知識每天! –

+0

如果我的回答對你有用,我可以請你選擇它作爲答案,並upvote它嗎? – Aacini

相關問題