backup files with batch

Associate
Joined
8 Mar 2007
Posts
2,176
Location
between here and there
hey all,

I need to backup files from a certain dir on to the network everynight.

The problem is i don't wnat to back up every file in the source folder just the file modified that day.

I could use robocopy but that would mean installing server tools 2003 (or whatever it is) on every machine.

how can i just copy the newly edited files??

any ideas?
 
You could write a fairly simple VB script (on the asumption that these are Windows based machines) to compare the last modified date on the files to the current date, and copy those that are different.
 
Funny you say that...

I was going to go down that route, but I don't know vbs at all. (i am aware that its a bit more powerfull than good old dos)

can i have an example please?
 
I'd try this:

xcopy source destination /D /C /E /I /K /O /Y

(if you want to know what each of the switches do - xcopy /? in command prompt - /D is the important one - it copies only files that have been modified)
 
Something like this will copy all files modified today:

Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("SourceFolder")
Set colFiles = objFolder.Files
 
For Each objFile in colFiles
    If objFile.DateLastModified > Date Then
        objFSO.CopyFile objFile.Path, "DestinationFolder\"
    End If
Next
 
Sadly that would require me entering the date. I'm going to add this to AD and let it run at logoff so need it to be completely automated.

thanks for the reply:)

I've used that before successfully - you can specify a date, but it works just fine without a date specified.
 
ok cool, thanks.

Whilst we're on the subject of dos..

I can export a line to a txt file by using; echo line to be exported>>c:\line.txt

That will make the txt file 'line' and add 'line to be exported' to the file.

does anyone know how i can bring it back in??

set string=<<c:\line.txt


or something?????
 
not to worry,

got it sorted.

set /P name=<D:\data\backup.txt (would take the first line from backup.txt and would be useable as a variable - name.

:)
 
Back
Top Bottom