By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!set dest=%2
iff ISFILE %dest then
do i = 1 to 65535
if ISFILE %@PATH[%2]%@NAME[%2](%i).%EXT[%2] ITERATE
set dest=%@PATH[%2]%@NAME[%2](%i).%EXT[%2]
LEAVE
enddo
endiff
copy %1 %dest
Question: When a filename in the target folder already exists, is there a simple solution, like appending "(2)" to the filename, before copying/moving the file to the target directory?
d:\>dir /b dir1
testfile.txt
d:\>dir /b dir2
testfile.txt
d:\>copy \dir1\testfile.txt %@version[\dir2\testfile.txt,_]
D:\dir1\testfile.txt => D:\dir2\testfile.txt_1
1 file copied
d:\>dir /b dir2
testfile.txt
testfile.txt_1
Take a look at the @VERSION function in TCC help, I think it will do what you want.