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?
There is no easy solution. You could turn on clobber mode and COPY will prompt you before overwriting an existing file.
Otherwise you'll have to write a custom COPY script that checks for an existing file and formats a new name based on the existing name.
This isn't checked, but should be close. You'll probably need to do something with quotes too if there are any spaces.
CustomCopy.btm:
Code:
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
A full blown COPY command would need to check for a destination directory, include lists, regular expressions, wild cards, etc. So an ideal solution would have to be done internally.
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?
Take a look at the @VERSION function in TCC help, I think it will do what you want. For example, if two directories DIR1 and DIR2 both contain a file called TESTFILE.TXT:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.