Computing.Net > Forums > Disk Operating System > Batch File

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File

Reply to Message Icon

Name: morphine
Date: March 29, 2005 at 08:00:39 Pacific
OS: NT
CPU/Ram: 1 GB
Comment:


I have a folder on our network with the following directory's:

- Mon
- Tues
- Wed
- Thur
- Fri
- Sat
- Sun

These 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 folder

Is this possible?



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: March 29, 2005 at 08:18:10 Pacific
Reply:

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.


0

Response Number 2
Name: morphine
Date: March 29, 2005 at 08:24:45 Pacific
Reply:

When I typed echo %Date% at the NT command prompt it just returned %date%.
Is that what you mean?


0

Response Number 3
Name: rogerashley
Date: March 29, 2005 at 08:29:14 Pacific
Reply:

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


0

Response Number 4
Name: morphine
Date: March 29, 2005 at 08:36:51 Pacific
Reply:

I just want to create a batch file and run it from the task scheduler in NT.


0

Response Number 5
Name: dtech10
Date: March 29, 2005 at 08:50:28 Pacific
Reply:

Hi
Not sure about the task scheduler in NT.
what doe's this command produce "date /t"



0

Related Posts

See More



Response Number 6
Name: morphine
Date: March 29, 2005 at 09:00:00 Pacific
Reply:

Tue 03/29/2005


0

Response Number 7
Name: dtech10
Date: March 29, 2005 at 09:11:55 Pacific
Reply:

@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.


0

Response Number 8
Name: dtech10
Date: March 29, 2005 at 09:16:26 Pacific
Reply:

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 as

required. Works in XP ok. Type "del /?" for more info.
rem Delete the echo's there there just for safety.


0

Response Number 9
Name: rogerashley
Date: March 29, 2005 at 09:16:54 Pacific
Reply:

Does this work in MS DOS 6.22 standalone ???

DO NOT BAN THE MESSENGER


0

Response Number 10
Name: dtech10
Date: March 29, 2005 at 09:22:13 Pacific
Reply:

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.



0

Response Number 11
Name: morphine
Date: March 29, 2005 at 09:54:05 Pacific
Reply:

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.



0

Response Number 12
Name: rogerashley
Date: March 29, 2005 at 09:58:58 Pacific
Reply:

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


0

Response Number 13
Name: rogerashley
Date: March 29, 2005 at 10:01:02 Pacific
Reply:

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


0

Response Number 14
Name: rogerashley
Date: March 29, 2005 at 10:02:30 Pacific
Reply:

"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 JW

DO NOT BAN THE MESSENGER


0

Response Number 15
Name: Mechanix2Go
Date: March 29, 2005 at 10:30:33 Pacific
Reply:

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.


M2

If at first you don't succeed, you're about average.


0

Response Number 16
Name: Mechanix2Go
Date: March 29, 2005 at 10:46:19 Pacific
Reply:

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


M2

If at first you don't succeed, you're about average.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Batch File

Help!! Batch File www.computing.net/answers/dos/help-batch-file/13525.html

Batch files - - Mapping network drive www.computing.net/answers/dos/batch-files-mapping-network-drive/3809.html

Pause batch file www.computing.net/answers/dos/pause-batch-file/2810.html