1.

Solve : want to copy/rename a particular file to desires name using batch file while run?

Answer»

Dear sir,

I am a accountant, while running my account package to display any desired information, a temporary file with the name data.rtf automatically created in background. The contants of data.rtf varies with every NEW display. I want to save this data.rtf file with my desires name using BATCH file command, please help me.

thank's
raviQuote from: ravi.ravi on July 04, 2010, 10:45:33 AM


A temporary file with the name data.rtf automatically created in background. The contants of data.rtf varies with every new display. I want to save this data.rtf file with my desires name using batch file command

C:\test>type ravi.bat
@echo off

copy c:\temp\data.rtf c:\test\desirename.rtf


Output:

C:\test>ravi.bat
1 file(s) copied.
C:\test>dir desire* | findstr "desire"
07/04/2010 12:14 PM 9 desirename.rtf

C:\test>Quote from: marvinengland on July 04, 2010, 11:20:50 AM
C:\test>type ravi.bat
@echo off

copy c:\temp\data.rtf c:\test\desirename.rtf


question: in this batch file it seems you would have to enter the desired name into the batch file while you are creating the batch file, i.e. before loading the display that you will want to save the temp file from.
How could one program interaction into he batch file instead, whereby each time a display was finished, the temp file would be saved with a new name that you would decide and enter while the batch file itself is running?Quote from: KB5cmd on July 05, 2010, 06:00:53 PM
question: in this batch file it seems you would have to enter the desired name into the batch file while you are creating the batch file, i.e. before loading the display that you will want to save the temp file from.
How could one program interaction into he batch file instead, whereby each time a display was finished, the temp file would be saved with a new name that you would decide and enter while the batch file itself is running?

With a commandline argument or prompt the user for the name.

I will show an EXAMPLE of each shortly.


C:\test>type ravi.bat
@echo off

copy c:\temp\data.rtf c:\test\%1.rtf

Output:

C:\test> ravi.bat newname
1 file(s) copied.
C:\test>dir *.rtf | findstr "newname"
07/04/2010 12:14 PM 9 newname.rtf

C:\test>
_________________________________


C:\test>type ravi2.bat
@echo off
set /p name=Enter name:

copy c:\temp\data.rtf c:\test\%name%.rtf




C:\test>ravi2.bat
Enter name: ravname
1 file(s) copied.
C:\test>dir /tc ravname.rtf | findstr "ravname"
07/05/2010 08:31 PM 9 ravname.rtf

C:\test>


Discussion

No Comment Found