Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I would like a bat file to copy files only if it is the first day of the month. I found an excellent post that is very close to what I need, but I'm not DOS savy enough to adapt it from day-of-week to day.
Thanks!!
McAhren
*********************************
Here is the post:Name: Secret_Doom
Date: July 31, 2003 at 12:32:49 Pacific
@echo off
for /F "tokens=1" %%D in ('date/T') do set day=%%D
for %%D in (Sat Sun) do if /i "%day%"=="%%D" (set day=&goto:eof)
set day=
echo This part will not be executed on
echo Saturdays nor Sundays.-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

The following script should fit your need:
@Echo Off
For /F "tokens=2 delims= /-" in ('Date /T') Do If not %%A==01 GoTo :EOFEcho This command runs only if the first day of the month
The problem here is the Date format as it relays on the country settings; so the command I posted assumes the European format day dd/mm/yyyy, but in USA it is day mm-dd-yyyy leading to tokens=3. By the way under Windows XP the Date command returns no day of week, so tokens must be adjusted scaling by one.
Warning: be sure to insert a space after the = ending delims.
I hope this helps, otherwise post again.

![]() |
need help in schedualing
|
Keyboard Buffer
|

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