PC Review


Reply
Thread Tools Rate Thread

copy and file name change

 
 
=?Utf-8?B?U3Rldmll?=
Guest
Posts: n/a
 
      17th Feb 2004
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

 
Reply With Quote
 
 
 
 
Phil Robyn [MVP]
Guest
Posts: n/a
 
      17th Feb 2004
Stevie wrote:

> 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 - - - - - - - - - -

--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m a i l
 
Reply With Quote
 
stevie
Guest
Posts: n/a
 
      18th Feb 2004
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-----
>Stevie wrote:
>
>> 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 - - - - -

- - - - -
>
>--
>Phil Robyn
>Univ. of California, Berkeley
>
>u n z i p m y a d d r e s s t o s e n d e - m a

i l
>.
>

 
Reply With Quote
 
Phil Robyn [MVP]
Guest
Posts: n/a
 
      18th Feb 2004
stevie wrote:

> 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.

>
>
>
>>-----Original Message-----
>>Stevie wrote:
>>
>>
>>>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 - - - - - - - - - -



--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m a i l
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select a file, copy it and change some data SandMaN Microsoft Excel Programming 0 15th Aug 2006 02:13 PM
copy/xcopy always change modified attribute of file? djc Microsoft Windows 2000 CMD Promt 2 11th Jun 2004 05:38 AM
copy and file name change Stevie Microsoft Windows 2000 File System 0 17th Feb 2004 03:05 PM
File Copy Name Case Change =?Utf-8?B?S2F0ZQ==?= Windows XP Help 0 2nd Jan 2004 04:06 PM
File attributes change on copy to another drive George Brims Windows XP Basics 8 18th Dec 2003 12:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:08 AM.