Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a folder on our network with the following directory's:- Mon
- Tues
- Wed
- Thur
- Fri
- Sat
- SunThese folders contain database backup files that are pretty large.
The server is getting low on disk space and I
want to create a batch file that will do the following:Monday delete the contents of the Thu folder
Tuesday delete the contents of the Fri folder
Wednesday delete the contents of the Mon folder
Thursday delete the contents of the Tue folder
Friday delete the contents of the Wed folderIs this possible?

Hi
I take your using the Command Prompt in NT.
What format doe's the "echo %Date%" command produce in NT as I think it's different from WinXP by echoing the Day of the week before the date is this so.

Are you wanting a "Standalone MS DOS and compatible" or "NT solution" ??, they are quite often different. If it is an NT solution it may be wise to post in the Programming or your O/S Forum
DO NOT BAN THE MESSENGER

@echo off
Set Day=%XDate:~0,3%echo %Day%
if '%Day%=='Mon echo del /q \Thu\*.*
if '%Day%=='Tue echo del /q \Fri\*.*
if '%Day%=='Wed echo del /q \Mon\*.*
if '%Day%=='Thu echo del /q \Tue\*.*
if '%Day%=='Fri echo del /q \Wed\*.*
rem The /q deletes without asking confirmation change as required. Works in XP ok. Type "del /?" for more info.
rem Delete the echo's there there just for safety.

Sorry Forget To add First Line
@echo off
for /f %%a in ('date /t') do set XDate=%%a
Set Day=%XDate:~0,3%echo %Day%
if '%Day%=='Mon echo del /q \Thu\*.*
if '%Day%=='Tue echo del /q \Fri\*.*
if '%Day%=='Wed echo del /q \Mon\*.*
if '%Day%=='Thu echo del /q \Tue\*.*
if '%Day%=='Fri echo del /q \Wed\*.*
rem The /q deletes without asking confirmation change asrequired. Works in XP ok. Type "del /?" for more info.
rem Delete the echo's there there just for safety.

Hi rogerashley
No. But neither does NT task scheduler.
Write one for standalone DOS if required, but would need to write a debug script to obtain the Day-of-week.

I was unable to get this to work.
I guess I will just create 5 seperate batch files for each day of the week and do it that way. Thanks for the help.

So if this is not for MS DOS 6.22 standalone how come it is in this forum?, and how relevent is it to MS DOS and compatible users?
http://83.67.55.228/
DO NOT BAN THE MESSENGER

morphine you try the programming forum as dtech10 pointed out NT tsak scheduler is not in DOS Standalone, which is what this forum is for!!!!!!!!!!!!!!!
DO NOT BAN THE MESSENGER

"Below is the DOS Standalone message area. This forum is for all Standalone versions of DOS, not the "DOS" prompt contained inside later versions of Windows."
This is what is at top of FORUM written by JWDO NOT BAN THE MESSENGER

dtech10 et al,
This should work in most DOS anf NT:
::**
@echo off > quit.bat
echo.|date>today:TUE
find /i "TUE" < today > nul
if errorlevel 1 goto WED
del FRI
quit:WED
find /i "WED" < today > nul
if errorlevel 1 goto THU
del MON
quit:THU
find /i "THU" < today > nul
if errorlevel 1 goto FRI
del TUE
quit:: and so on
::**Notes:
For versions which support it, use del /q.
For others, use echo y|del
The default file mask for a DEL is *.*, so this:
del thu
is equivalent to:
del thu\*.*
Also, this uses FIND but no DEBUG.
For versions of FIND which do not support /i it will need to have the day string hardwired. "Tue" NOT "TUE".
For a bat to get DAY DATE & TIME into vars using NO external commands, see my world famous DTWINALL posted several months ago.
M2If at first you don't succeed, you're about average.

Hi Morphine,
Try #15.
The Set Day=%XDate:~0,3% is much more elegant, but depends on the date layout on the particular box.
Read the notes. As is it will prompt you to confirm the DEL. After you are comfortable with the script you can tailor it to run with no prompt.
Wide ranging deletes with an untested script are a BAD idea.
Not also that as written by dtech10, the directories to be cleared are off the root.
The one I wrote assumes the BAT is in the directoru immediately above the data dirs.
You can hardwire the paths or, much better, lead in with a CD.
HTH
M2If at first you don't succeed, you're about average.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |