I have a batch file that FTPs a text file from a server to the user's PC. However sometimes the file is needed to be FTPed more than once a day. When we attempt to FTP it again, since there is a file with the same name already in that directory we get the following:
A duplicate file name exists, or the file
cannot be found.
Press any key to continue . . .
How can I tell the batch file to add one digit to the end of the file name so that we don't have this duplicate issue.
For example:
09-20-07file1.txt
09-20-07file2.txt
09-20-07file3.txt
...etc.
That is a simplified example; in reality the file names would look more like this:
audit.dump.%dumpdate%.LK%dumptid%001.txt
audit.dump.%dumpdate%.LK%dumptid%002.txt
audit.dump.%dumpdate%.LK%dumptid%003.txt
...etc.
Here is the part of the code that is relevant:
~
:LOOP1
Echo Enter the TID (xxxxxx) for the Audit Dump.
Echo.
Set /P dumptid= ^>
Echo.
Echo Enter the Date (yy-mm-dd) for the Audit Dump.
Echo.
Set /P dumpdate= ^>
Echo.
Echo.
Echo The Audit Dump's TID and Date that you entered are %dumptid% and %dumpdate%.
Echo Press Y or y and then ENTER if correct or press ENTER to retry.
Echo.
Set /P answ= ^>
Echo.
Echo.
Echo.
If /I not "%answ%."=="Y." GoTo :LOOP1
cd c:\ftp_temp
> latest.ftp.request.txt echo o %qastratusip%
>> latest.ftp.request.txt echo %qastratususername%
>> latest.ftp.request.txt echo %qastratuspassword%
>> latest.ftp.request.txt echo bin
>> latest.ftp.request.txt echo cd audit_dumps
>> latest.ftp.request.txt echo get %dumptid%.%dumpdate%.prt
>> latest.ftp.request.txt echo bye
ftp -s:latest.ftp.request.txt
REM *****************Start of Last FTP Request Time Stamp***************
echo @prompt set date=$d$_set time=$t$h$h$h > {a}.bat
%comspec% /e:2048 /c {a}.bat > {b}.bat
for %%v in ({b}.bat del) do call %%v {?}.bat
echo %date% %time% >> latest.ftp.request.txt
REM *****************End of Last FTP Request Time Stamp*****************
rename %dumptid%.%dumpdate%.prt audit.dump.%dumpdate%.LK%dumptid%.txt
Set dumptid=
Set dumpdate=
Set answ=
Pause
goto start
~
Thanks,
REMGU