Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename file on date

Status
Not open for further replies.

vespin

Technical User
Sep 17, 2001
17
US
Greetings,

I'm really new to C++, but I'm attempting to create a program that will rename two files on a certain date. The files are:

c:\orrtax\2001\sys\ot2001.bat and c:\orrtax\2001\sys\ot2001nd.bat and I want to have them renamed on october 31st 2003. Does anyone have any sample code that will help with this?

In the meantime I will search for a book.

Kelly

I would use a batch file and put it in the scheduler, but it's for a friend who has win 95.
 
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>

main()
{
struct tm *newtime;
time_t aclock;

while(1)
{
time(&aclock);
newtime = localtime(&aclock);
if(strcmp(&quot;Mon Oct 07 17:53:00 2002\n&quot;, asctime(newtime)) == 0)
{
system(&quot;ren file1.bat file2.bat&quot;);
}
Sleep(500);
}
return(0);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top