1.

Solve : batch file find by date?

Answer»

I see a bat file that returns a date....
but I TRYING to find out if I have a folder "BANNER" and inside "banner" I have sub folders.
main folder: "banner"
sub folders: "monday", "tuesday", "wednesday", "thursday", "friday", "weekend"

Is there a POSSIBLE way to say If today is monday, SCAN the monday folder and if there is "file" overwrite with "file" with this "file" then exit. And so on for the other days/folders. Quote

I see a bat file that returns a date

The format of the date will determine how to write the batch code. This snippet is designed for DOW mm/dd/yyyy

Code: [Select]echo off
set dow=%date:~0,3%
set dowf=weekend
if %dow%==Mon set dowf=Monday
if %dow%==Tue set dowf=Tuesday
if %dow%==Wed set dowf=Wednesday
if %dow%==Thu set dowf=Thursday
if %dow%==Fri set dowf=Friday
if exist c:\banner\%dowf%\file copy /y file c:\banner\%dowf%\file

You'll need to change any references to file.

Good luck.
Bad luck if your local settings don't use US date format! (There are a few billion people who don't.) My European locale just has a date like this 03/08/2008. No day of the week string.



Discussion

No Comment Found