Solved

bacth file question

Posted on 2004-04-01
4
163 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
ID: 10732297
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
ID: 10732350
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
ID: 11951812
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 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

11 Experts available now in Live!

Get 1:1 Help Now