Solved

bacth file question

Posted on 2004-04-01
4
156 Views
Last Modified: 2010-04-12
dos batch file
not sure if thsi is even possible have looked around on the web and can't seem to find out how to do it. any feed back well appreciated. all i wanna do is check the date a file was created and if it's older than x do something this might make it simpler

batch file

net time \\192.168.0.2 /set /y
net use x: \\192.168.0.2\tbackup
net use y: \\192.168.0.2\mbackup


check date of backup file in mbackup if older than 1 month force backup and place in mbackup

ntbackup backup "C:\documents and settings\%username%" /f "C:\backup\%username%.bkf"



check date of backup in tbackup if older than 5 days ask do they wanna do a backup and place in tbackup


if yes

ntbackup backup "C:\documents and settings\%username%" /f "C:\backup\%username%.bkf"

else
exit


tbackup is temp'e backup
mbackup is monthly backup


cheers in advance

0
Comment
Question by:jim_bob2003
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
infradawn earned 125 total points
Comment Utility
You'll have to do the calendar math yourself but here's the skeleton:

>>>

@echo off
set thefile=temp_script.vbs

rem create datestamp (handles both W2K and 2K3 returned dates)
for /f "tokens=1-3* delims=/ " %%i in ( "%date:~-10%" ) do (
   set nowday=%%i
   set nowmonth=%%j
   set nowyear=%%k
)

rem get file datestamp
for /f "tokens=1-3 delims=/ " %%i in ('dir /tw temp_script.vbs^|find "%thefile%"') do (
   set fileday=%%i
   set filemonth=%%j
   set fileyear=%%k
)

echo %thisfile%
echo File modified: %fileday%/%filemonth%/%fileyear%
echo Today is: %nowday%/%nowmonth%/%nowyear%

set /a yeardiff=%nowyear%-%fileyear%
set /a monthdiff=%nowmonth%-%filemonth%
set /a daydiff=%nowday%-%fileday%

echo Years diff: %yeardiff%
echo Months diff: %monthdiff%
echo Days diff: %daydiff%

pause

<<<


iD
0
 
LVL 3

Expert Comment

by:infradawn
Comment Utility
Oh, should've said: line 2, "temp_script.vbs" is just a test file I pulled the modify date back from while playing with the script.

:)
0
 
LVL 9

Expert Comment

by:jdeclue
Comment Utility
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    Accept: infradawn {http:#10732297}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

jdeclue
EE Cleanup Volunteer
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now