Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

bacth file question

Posted on 2004-04-01
4
Medium Priority
?
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
infradawn earned 500 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

618 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