Solved

bacth file question

Posted on 2004-04-01
4
160 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

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…
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

18 Experts available now in Live!

Get 1:1 Help Now