copy and file name change

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys

I have a file that I need to back-up every 2 hours, as it gets overwritten. I want to do this by setting up a bat file to copy the file to a Logs directory. I will then schedule windows 2000 to run this every 2 hours

My problem is that it will overwrite my previous back-up as it is in the same name. Is there a way to code a bat file to copy a file and write it to a location with a name change that increments by one.. ie InfoFile.xls backs-ups would be InfoFile1.xls, InfoFile2.xls InfoFile3.xls ec

Or does anyone else have a more practical solution.
Please try to keep it as simple as possible as I'm a novice user
 
Stevie said:
Hi guys.

I have a file that I need to back-up every 2 hours, as it gets overwritten. I want to do this by setting up a bat file to copy the file to a Logs directory. I will then schedule windows 2000 to run this every 2 hours.

My problem is that it will overwrite my previous back-up as it is in the same name. Is there a way to code a bat file to copy a file and write it to a location with a name change that increments by one.. ie InfoFile.xls backs-ups would be InfoFile1.xls, InfoFile2.xls InfoFile3.xls ect

Or does anyone else have a more practical solution.
Please try to keep it as simple as possible as I'm a novice user.

- - - - - - - - - - begin screen capture Win2000 - - - - - - - - - -
C:\cmd>dir /o-d \junkdir\InfoFile*.xls | find "/"
02/17/2004 11:29a 0 InfoFile0003.xls
02/17/2004 11:29a 0 InfoFile0002.xls
02/17/2004 11:29a 0 InfoFile0001.xls

C:\cmd>demo\BackupInfofile
copy InfoFile.xls \junkdir\InfoFile0004.xls

C:\cmd>rlist demo\BackupInfofile.cmd
=====begin C:\cmd\demo\BackupInfofile.cmd ====================
1. @echo off
2. setlocal
3. dir /b /o-d \junkdir\InfoFile*.xls > c:\temp\wrkfile.
4. set /p last_num=<c:\temp\wrkfile.
5. set last_num=%last_num:InfoFile=%
6. set /a next_number = 1%last_num:.xls=%+1
7. set next_number=%next_number:~1%
8. echo copy InfoFile.xls \junkdir\InfoFile%next_number%.xls
=====end C:\cmd\demo\BackupInfofile.cmd ====================
- - - - - - - - - - end screen capture Win2000 - - - - - - - - - -
 
Wow Phil, looks like a solution!

But what do I need to do??

What is BackupInfofile.cmd? Is this a file I need to
create, and then call it in a bat file?

-----Original Message-----
it gets overwritten. I want to do this by setting up a
bat file to copy the file to a Logs directory. I will
then schedule windows 2000 to run this every 2 hours.up as it is in the same name. Is there a way to code a
bat file to copy a file and write it to a location with a
name change that increments by one.. ie InfoFile.xls
backs-ups would be InfoFile1.xls, InfoFile2.xls
InfoFile3.xls ect
 
stevie said:
Wow Phil, looks like a solution!

But what do I need to do??

What is BackupInfofile.cmd? Is this a file I need to
create, and then call it in a bat file?

Hi, Stevie,

BackupInfofile.cmd *is* a batch file. If you make whatever
changes are appropriate for your situation (like changing
the name of the directory) and remove the word 'echo' from
line 8 (added for demonstration purposes only), it should
work for you.
 
Back
Top