|
OK - this is a bit longer than I expected, but it does the job and shows you the techniques to extend it. This code does assume that you are running WinNT 4 or later. I have only tested it on XP.
You can find lots of info about building batch files in Windows NT Shell Scripting, by Tim Hill. A chapter of this book is available on the Code Project web site.
Mark
=============== batch script ======================================
@echo off
setlocal enabledelayedexpansion
::===============================================================
:: Oldfiles.bat
:: Usage: Oldfiles [minutes]
:: Arguments: Minutes - the maximum age of files
::
:: This script looks through the files in the current directory
:: (and its sub-directories) and lists all the files that are older
:: than the number of minutes entered on the command line.
:: Specify the number of minutes to check for
if [%1]==[] (
set /a AGELIMITMIN = 60
) else (
rem This should fail if %1 is not a valid number
set /a AGELIMITMIN = %1
)
rem Note that %TIME% is in 24 hour format, unlike the timestamp on files
echo %TIME%
:: format hh:mm:ss.ss - 24hr clock
for /f "tokens=1-3 delims=: " %%a in ("%TIME%") do (
set CHH=%%a & set CMIN=%%b & set CSS=%%c
)
echo %DATE%
:: format DDD MM/DD/YYYY
for /f "tokens=1-4 delims=/ " %%a in ("%DATE%") do (
set WDAY=%%a & set CMON=%%b & set CDD=%%c & set CYYYY=%%d
)
::strip any leading zeros so the math will work (leading zeros imply octal)
::hours don't have leading zeros, just a leading space
if %CSS% LSS 10 set CSS=%CSS:~1,1%
if %CMIN% LSS 10 set CMIN=%CMIN:~1,1%
rem knock off any leading or trailing spaces
set /a CHH = CHH
set /a CDD = CDD
set /a CMON = CMON
::calculate the number of minutes since the start of the month
set /a TMSTAMP = CDD*24*60 + CHH*60 + CMIN
set /a LIMITSTAMP = TMSTAMP - AGELIMITMIN
echo CurMin = %TMSTAMP% LIMIT = %LIMITSTAMP%
rem here's where we set the time period of 1 hour
if %LIMITSTAMP% LSS 0 (
echo This program does not work in the first
echo %AGELIMITMIN% minutes of a month!!
echo Quitting
echo.
goto :EOF
)
rem echo %HH% %MIN% %SS%
rem echo %WDAY% %DD%/%MON%/%YYYY%
::loop recursively through all the files in the current directory
:: and all lower directories
for /r %%I in (*.*) do (
rem echo %%~tI %%I
set OLD=TRUE
rem MM/DD/YYYY HH:MM PM
call :PARSEFILETIME %%~tI
set /a FTMSTAMP = DD*24*60 + HH*60 + MIN
rem Find any files that are older than the limit
rem these checks assume that AGELIMIT is less than a month
if !YYYY! GEQ !CYYYY! (
if !MON! GEQ !CMON! (
if !FTMSTAMP! GEQ !LIMITSTAMP! (
rem file is newer than the cutoff time
set OLD=FALSE
)
)
)
if [!OLD!]==[FALSE] (
echo %%I is new enough. %%~tI !HH!:!MIN! !FTMSTAMP!
) else (
rem Here is where you would delete old files
rem or you could accumulate the names in a file
rem for later deletion
rem echo %%I is too old and will be deleted.
)
)
::Now loop through the directories
for /r /d %%I in (*.*) do (
rem echo %%~tI %%I
set OLD=TRUE
rem MM/DD/YYYY HH:MM PM
call :PARSEFILETIME %%~tI
rem echo !YYYY!/!MON!/!DD! !HH!:!MIN!
set /a FTMSTAMP = DD*24*60 + HH*60 + MIN
rem Find any directories that are older than the limit
rem these checks assume that AGELIMIT is much less than a month
if !YYYY! GEQ !CYYYY! (
if !MON! GEQ !CMON! (
if !FTMSTAMP! GEQ !LIMITSTAMP! (
rem file is newer than the cutoff time
set OLD=FALSE
)
)
)
rem echo %%I %%~tI !FTMSTAMP!
if [!OLD!]==[FALSE] (
echo %%I is new enough. %%~tI !HH!:!MIN! !FTMSTAMP!
) else (
rem Here is where you would delete old directories
rem echo %%I is too old and will be deleted.
)
)
goto :EOF
::================================================
:: PARSEFILETIME
:: Arguments: Timestamp
:: format MM/DD/YYYY HH:MM PM (format from %~t)
:: Returns: sets variables MON, DD, YYYY, HH, MIN
::================================================
:PARSEFILETIME
set RET=FALSE
rem Should do some checks for valid format
for /f "tokens=1-6 delims=:/ " %%a in ("%*") do (
set MON=%%a
set DD=%%b
set YYYY=%%c
set HH=%%d
set MIN=%%e
set AMPM=%%f
)
rem set /a math thinks leading zeros imply octal numbers,
rem so get rid of them
if %MON% LSS 10 set MON=%MON:~1,1%
if %DD% LSS 10 set DD=%DD:~1,1%
if %HH% LSS 10 set HH=%HH:~1,1%
if %MIN% LSS 10 set MIN=%MIN:~1,1%
rem echo !MON! !DD! !YYYY! !HH! !MIN!
rem deal with 12:30 am = 00:30 hrs and 12:30 pm = 12:30 hrs
if !HH! EQU 12 set /a HH=!HH! - 12
if [%AMPM%]==[PM] set /a HH=!HH! + 12
rem Should return false if format is wrong
set RET=TRUE
goto :EOF
|
|
|
|
|
Hi,
I have an email server: MS Exchange Server
How can I configure the email server checks for valid email address before sending
Thanks in advance
|
|
|
|
|
As far as I'm aware Exchange already checks for address validity. It's a tricky thing to check as although RFC2822[^] lists the valid characters, in practice some email systems do not conform to this specification and permit characters not permitted in RFC2822.
If a user specifies an address that is not a valid domain (right-hand side of @), Exchange (if configured for direct delivery) will be unable to resolve the MX records in DNS for that domain, and will abandon the message with a non-delivery report [NDR] (a type of delivery status notification [DSN]). If a user specifies an invalid local-part (left-hand side of @), the receiving server will abandon the message with its own NDR. If the return address is invalid or incorrect, Exchange will abandon sending the NDR. If it detects that it would be trying to send an NDR for an NDR in response to a message that it originated (detecting its own address in the Received headers), it will not send the NDR.
If you're configured to use a Smart Host, Exchange will pass outgoing messages directly onto the smart host rather than checking the domain part. If the domain part is invalid the smart host will generate an NDR.
By default Exchange attaches the whole of the original message to the NDR when it is generated. We have had a problem with our upstream ISP blocking access to their SMTP server (we use a Smart Host configuration) due to a large amount of viral content originating from our server. Investigation showed that this was incoming viral content that couldn't be delivered to a user on our server (invalid destination address), and therefore was attached to the NDRs.
I've now limited the maximum size of any DSN to strip off any attachments, which saves bandwidth. To do this, see XCON: Option to Strip Attachments for Messages That Generate an NDR[^]. You must spell the registry keys exactly as written - even if you think it's misspelled! This originally caught me out.
To check your Exchange setup for errors, download the Exchange Best Practices Analyzer Tool[^].
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
How to create a Virtual Drive as like GMail Drive.
Purpose : Sync Files local Machine to Server Storage Area. (as like Gmail Drive and its Properties.)
can this done using Shell Programming ?
pls suggest.
Sriram
|
|
|
|
|
I found the way to mount and create virtual drive for floopy disk in here.[^] Please check it and let me know whehter is match what you need or not...
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi there.
Thanks for your link. its really nice.
i have a requirement of Creating a Virtual Drive as like Google Gmail Drive.
any other source of Creating Virtual Drive as like VFD ?
Regards
Sriram
|
|
|
|
|
Try to search in www.google.com .
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
I require some assistance with a unique problem, and as I am not much in the way of an Win32 API programmer, was hoping someone could help me out.
I am configuring an application for a customer that would like a hotkey setup for a specific program function; however, the application itself does not support the space bar as a hotkey.
I was looking at maybe trapping the space bar for this specific application and remapping the key as a hotkey that it does support (like F12), but leaving the space bar functionality intact for other programs also running. I have no idea how to go about doing this, whether it can be done, or if it is even the best solution for the problem.
I do not have access to the application code for which I am trying to add this additional support to.
Does anyone have any suggestions? Thanks
|
|
|
|
|
Berkelium wrote:
I am configuring an application for a customer that would like a hotkey setup for a specific program function; however, the application itself does not support the space bar as a hotkey
What is the software development that you use to develop a customer application to use hotkey???
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi, I have a problem in Microsoft access 2000. I have build my own Ms access application which contain table, query, form, report... My problem is when I start to run the form, my Ms access application is close immediately. But if I open the table or query, it is fine and run normally. I don't know what is the reason but that make me waste a lot of my time to save the record in the database. Does anybody know what is the reason come from???
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Have you, perhaps, created a on_click or on_open event handler that shuts it down? It's awfully easy to inadvertently create an event handler that does unexpected things in Access 2000...
Is there any code related to the form that you can post?
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|
|
Thank you very much for your reply but I don't have any code in the the OnClick or OnOpen event handler. But if I log of my computer and logon again, then the form that I try to run could run successfully.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi, I have a question about the VGA card. My computer mainboard has a built-in VGA on it. So I don’t need to add additional VGA card to the board. Just install driver then the graphic would display correctly. My question is: if I install a VGA card on the PCI slot, does the main board accept it??? Do I need to do any special configuration to change from VGA on the build-in mainboard and VGA card???
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Yes you can... but first you must disable your onboard VGA in BIOS setup menu. See your motherboard manual how to disable it
|
|
|
|
|
Thank you very much for your information.
|
|
|
|
|
there's usually an option in the bios to set whether your motherboard should use the onboard graphics or a screen card. on my computer i select that my "boot from screen" is "agp" or "onboard". look for a similar setting...
--
Raoul Snyman
Saturn Laboratories
e-mail: raoul.snyman@saturnlaboratories.co.za
web: http://www.saturnlaboratories.co.za/
blog: http://blog.saturnlaboratories.co.za/
linux user: #333298
|
|
|
|
|
Thank you very much for your information.
|
|
|
|
|
if are using WindowsXP Pro/Home Edition u first sign ur VGA card in slot of motherboard resatrt ur PC then u will see new hardware and maybe u should (usually you should) install drivers for VGA card.
if u user another OS Windows, tell me which maybe we can helps you...
|
|
|
|
|
Thank you very much for your information.
|
|
|
|
|
I'm converting postscript forms from VPS/ANYQUEUE to a web application and I need to know to re-build the forms that were used (primarily standard greybar in landscape and portrait).
How do I rebuild them and get the Postscript overlays to work (Ghostscript ?)
|
|
|
|
|
Hi I tried customizing my right click menus. I managed to insert an extra menu to start one of my own applications.
But when I select more than one file and try to start the application it starts a copy of it for every selected file.... I would like it to start one single copy and hand over each filename as parameters. Kind of like when you have the compress file option in the Right Click menu. It compresses all the files into one archive and doesn't make a different archive for every file.
Thx for your help.
zsomboro
|
|
|
|
|
|
Hi, in windows xp, I found a command shutdown from the MS-DOS command line. But now I want to know are there any command that is available for us to hibernate a computer from the command line too??
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi,
shutdown /h
Cheers
Phil Hobgen
Southampton, UK
|
|
|
|
|
Sorry, it is not working. Where do you get this kind of the information from???
|
|
|
|