Backup File

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
gansh
Posts: 1
Joined: 04 Aug 2010 02:48

Backup File

#1 Post by gansh » 04 Aug 2010 03:55

I want to create a bat file to create backup of a file. Bat file will get the file as parameter and then it will create a backup by copying it with a different name.
For Example
mybat.bat index.asp
will create index_1.asp

I did this. But the problem is that I want to have a check system while copying file.
if index_1.asp exists then it will create index_2.asp instead of index_1.asp

And the index will increase until the file not exists. I did something but
IF NOT EXISTS always gives me error.

THX FOR HELP.

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Backup File

#2 Post by !k » 04 Aug 2010 06:39

See as done it in this batch http://forum.wincmd.ru/viewpost.php?p=62933
It is invoked as: addcnt.cmd "list of files & dirs" "d:\folder 4 backups\"
File format "list of files & dirs" is:

Code: Select all

c:\path\name.txt
c:\long path\long name.txt
c:\folder\
c:\and folder too\

Batch conveniently used in conjunction with "Total Commander" filemanager, which sends the list of selected items in this format as a parameter %L. "D:\folder 4 backups\" can be omitted.
Command "&chcp 1251> nul" you probably do not need, remove it.
The report indicates:
echo 9999 units in the destination,
echo insufficient bits of counter.

Post Reply