Computing.Net > Forums > Programming > append a number tonew file created

append a number tonew file created

Reply to Message Icon

Original Message
Name: remgu
Date: September 20, 2007 at 12:10:02 Pacific
Subject: append a number tonew file created
OS: XP
CPU/Ram: P4 3.4Ghz 3GB Ram
Model/Manufacturer: Clone
Comment:

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.

Thanks,
REMGU


Report Offensive Message For Removal


Response Number 1
Name: ghostdog
Date: September 20, 2007 at 19:05:49 Pacific
Subject: append a number tonew file created
Reply: (edit)

show the code you have


Report Offensive Follow Up For Removal

Response Number 2
Name: remgu
Date: September 21, 2007 at 10:02:58 Pacific
Subject: append a number tonew file created
Reply: (edit)

Here is the part 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


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: append a number tonew file created

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge