Sign in to follow this  
Followers 0
Elkie

Help Me With Backup Script

12 posts in this topic

Can anyone help me please, how can i make script to backup files in certain folder before i replace them with a the files from another folder. for example:

i have a,b,c,d,e files in F1 Folder

and updated b,c files in F2 Folder

those b,c in the F1 will be replaced by those in F2, can autoIT make a backup of them to F3 Folder before i replace them.

Please i need it badly. thank you for reading and helping me out. :o

Share this post


Link to post
Share on other sites



how do you replace them? if you use autoit than you can do it by starting a filecopy first

if not is there a window you can read the text (where it maybe tells the filename)?

Yes, my plan is to use filecopy and *.* from the source dir to the destination dir, but my problem here is before the replace process started, i want to make the backup of the "will be replaced" files in the destination dir to a folder, lets just say Folder3: but how?

[Folder1]=a,b,c,d,e (destination dir)

[Folder2]=b,c (source dir)

[Folder3] (backup dir)

i wanna backup Folder1's "b,c" before i replace it with Folder2's "b,c" and save it in Folder3

can u help me?

Share this post


Link to post
Share on other sites

$desdir = "c:\";destination dir
$srcdir = "c:\test\";source dir
$bakdir = "c:\backup\";backup dir
;lets say you want to copy all files from the source dir to the destination dir
$files = filefindfirstfile($srcdir & "*.*")
while 1
$file = filefindnextfile ($files)
if @error than exitloop
if fileexists ($desdir & $file) then filecopy ($desdir & $file, $bakdir & "*")
wend
filecopy ($srcdir & "*", $desdir & "*", 1)

i was interrupted so maybe there is a little mistake

hope this works for you

good luck and have fun

Share this post


Link to post
Share on other sites

$desdir = "c:\";destination dir
$srcdir = "c:\test\";source dir
$bakdir = "c:\backup\";backup dir
;lets say you want to copy all files from the source dir to the destination dir
$files = filefindfirstfile($srcdir & "*.*")
while 1
$file = filefindnextfile ($files)
if @error than exitloop
if fileexists ($desdir & $file) then filecopy ($desdir & $file, $bakdir & "*")
wend
filecopy ($srcdir & "*", $desdir & "*", 1)

i was interrupted so maybe there is a little mistake

hope this works for you

good luck and have fun

Mmh. first of all, thanks for the post but i don't know what's but i find it copies all of the destination folder files perhaps because they have almost simillar names (ie:john1.au,john2.au....) :o

Share this post


Link to post
Share on other sites

it should just copy the files you replace

if you only replace some files you have to change the script to

$desdir = "c:\";destination dir
$srcdir = "c:\test\";source dir
$bakdir = "c:\backup\";backup dir
$file = "the copy file.cpy"
if fileexists ($desdir & $file) then filecopy ($desdir & $file, $bakdir & "*")
filecopy ($srcdir & $file, $desdir & $file, 1)

this was for 1 file

if you use some files try:

dim $file[100];$file[0] --> $file[99]
$desdir = "c:\";destination dir
$srcdir = "c:\test\";source dir
$bakdir = "c:\backup\";backup dir
$file[0] = 10; number of files you want to copy
$file[1] = "first copy"
$file[2] = "second copy"
...
$file[10] = "last copy"
for $i = 1 to $file[0] step 1
if fileexists ($desdir & $file[$i]) then filecopy ($desdir & $file[$i], $bakdir & "*")
next
for $i = 1 to $file[0] step 1
filecopy ($srcdir & $file[$i], $desdir & $file[$i], 1)
next

works with an array

maybe now this is what you need

Share this post


Link to post
Share on other sites

it should just copy the files you replace

if you only replace some files you have to change the script to

$desdir = "c:\";destination dir
$srcdir = "c:\test\";source dir
$bakdir = "c:\backup\";backup dir
$file = "the copy file.cpy"
if fileexists ($desdir & $file) then filecopy ($desdir & $file, $bakdir & "*")
filecopy ($srcdir & $file, $desdir & $file, 1)

this was for 1 file

if you use some files try:

dim $file[100];$file[0] --> $file[99]
$desdir = "c:\";destination dir
$srcdir = "c:\test\";source dir
$bakdir = "c:\backup\";backup dir
$file[0] = 10; number of files you want to copy
$file[1] = "first copy"
$file[2] = "second copy"
...
$file[10] = "last copy"
for $i = 1 to $file[0] step 1
if fileexists ($desdir & $file[$i]) then filecopy ($desdir & $file[$i], $bakdir & "*")
next
for $i = 1 to $file[0] step 1
filecopy ($srcdir & $file[$i], $desdir & $file[$i], 1)
next

works with an array

maybe now this is what you need

oh yes sorry i forgot to mention it, i will use the backup method as a part of my update files script. the files will vary in every update, i mean this script will:

1. see how many files on the source dir

2. locate (compare) the files on the destination dir with the files on the source dir(which the files will vary on every update) ie: update1: destFold[a,b,c,d] on another update destFold[e,f,g].

3. copy "only" the similar files between destination files and source files to backup dir

all i wanna tell is the file will be different every update

Thanks :o

Share this post


Link to post
Share on other sites

than the first script i posted should do the job, but as i said there might be a mistake

$desdir = "c:\";destination dir
$srcdir = "c:\test\";source dir
$bakdir = "c:\backup\";backup dir
;lets say you want to copy all files from the source dir to the destination dir
$files = filefindfirstfile($srcdir & "*.*")
while 1
$file = filefindnextfile ($files)
if @error than exitloop
if fileexists ($desdir & $file) and not $file = "." and not $file = ".." then filecopy ($desdir & $file, $bakdir & "*")
wend
filecopy ($srcdir & "*", $desdir & "*", 1)

this should work now, corrected 1 mistake

just try it and give me a short reply

Share this post


Link to post
Share on other sites

Hmmh, that's odd the replace is success but there's no backup created?

would it be because i wrongly type the "dot"? ($file = "." and not $file = "..") :o

Share this post


Link to post
Share on other sites

:o Anybody can help me please with my problem

i wanna to build an auto updater script, and the script will be put on the startup folder to auto execute when the user login.

it will check the file on another PC folder(source), if its a different version then the script will automatically replace the similar one with the source files. My problem is can autoIT copy the similar files on the destination dir with the one on the source dir to another folder(backup folder) before the replace process began?how?.

Nuffilein805, if u have another idea please give it to me.

Share this post


Link to post
Share on other sites

Are you having problems with

1: identifying which files to update,

2: which files to backup, or

3: how to copy them to the right place?

All these are logic and program flow questions, and reading the AutoIT help file for filecopy and filemove should answer most questions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0