reading a txt file with dos

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

I want to make a simple batch file to back files from a folder on my laptop to a folder on my PC when I'm using the laptop at home.

I intend to put it in the startup folder to run every time it starts up. I used a simple "if exist" command to check if the Pc folder is available and used a loop to re-try 3 times (allowing time for network connection)

I would like to only back up files that have been changed within the last 2 days.

I started thinking that i could use "date /t >>c:\date.txt" to output it and then bring it back in as a value, then use that value with the Xcopy command with the date switch.

The problem is that the date /t command outputs in the dd/mm/yy format when the Xcopy command is expecting dd-mm-yy

Is there any way to change the format or even read just parts of a txt file line and use the dd, mm and yy on their own. (ie, date /d:%dd%-%mm%-%yy% or something)

any ideas?
 
Nevermind just checked and you already said about xcopy.

You may have to look into using vbs to do this instead. Check out www.microsoft.com/technet and look at the script center there. You should be able to piece together a script which will do what you need
 
Last edited:
I've checked Xcpoy /? and can't see a switch that would do that function.

do you know what switch is it??

cheers dude
 
robocopy? that not a standard dos (win xp prompt) command, at least i can't find it.

these no real reason not to use synctool, except the fact I'd rather write it my self, mainly cos I'm sad like that.
 
Use xcopy to only copy files over with the archive bit set, after the copy then reset the archive bit, any files you later modify will have the archive bit set and will be copied over on next logon.

In fact you can use the /M switch in xcopy to copy over files with the archive bit set and then reset the bit.
 
robocopy is part of the resource kit - get it if you need this . If xcopy can't quite do it, robocopy will.

This will give you the date otherwise, though:

Code:
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do (
	set dow=%%d
	set day=%%e
	set month=%%f
	set year=%%g
)

for /f "tokens=1-5 delims=: " %%d in ("%time%") do (
	set hours=%%d
	set minutes=%%e
	set secs=%%f
)

echo %dow% %day% %month% %year%
echo %hours% %minutes% %secs%
 
if you're going to get robocopy and write a script why not just go the whole hog and get synctoy!
 
cheers for the post guys,

I got it working, used robocopy in the end. (damm it's got a load of functions!)

cheers again!
 
Back
Top Bottom