I would like to create a batch file that I can assign to an icon. that will copy a directory to another area of the hard drive and rename the directory with the name of the week and overwrite if an old one exists.
for instance this monday when hit the icon would copy c:meddata to c: monday meddata, On Tuesday would copy to C:tuesday meddata etc. and the following tuesday would overwrite the old tuesday. Is this possible?? Like XCOPY and pick the name of the weekday.
Jerome
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
XCOPY batch file that takes its name from weekday (Windows XP)
Home » Forums » AskWoody support » Windows » Windows Vista, XP and earlier » Questions: Vista, XP back to 3.1 » XCOPY batch file that takes its name from weekday (Windows XP)
- This topic has 45 replies, 8 voices, and was last updated 20 years, 6 months ago.
AuthorTopicWSjrklein
AskWoody LoungerJune 1, 2003 at 2:39 am #388345Viewing 2 reply threadsAuthorReplies-
WSTimOz
AskWoody LoungerJune 1, 2003 at 7:26 am #681464In a word, yes. A couple of things to consider:
If you want to fully replace the date from last week, you should probably delete the old directory and then follow with the xcopy. Otherwise the directory will contain files from last week that don’t exist today.
I don’t know of a direct source for the name of the day of the week. Simplest option would probably be to schedule a small task to run daily to either set an environment variable to the day (eg todayis=monday), or to create an empty file with the name (eg file monday in directory todayis), and then use that in your bat. There may also be an old dos utility that can do it in your bat.
-
WSJohnGray
AskWoody LoungerJune 1, 2003 at 8:05 am #681466The problem with XP and BATch files is that DATE /T in some regional settings no longer gives you the day of the week. (In Geek Mode, I can give you the full list of the 83 or so possible Regional Settings, and which still do or don’t give the DoW!!).
On my (UK) NT4 and W2K boxes at work, DATE /T would give “Sun 01/06/2003”,
On my (UK) XP box at home, I get “01/06/2003”
Have a look at your (US) XP box, and say what DATE /T gives you. I suspect it will be “Sun 06/01/2003”. If so, then it’s easy!Tim is right about the “delete directory before copy” problem; an alternative is to use ROBOCOPY from the XP Resource Kit, which will mirror one directory to another (among many other things) if asked, or XXCOPY, which does a very similar job.
Here’s something which you may be able to use/build on…
@echo off setlocal :: get today's DoW, assuming US settings "DoW mm/dd/yyyy" for /f "tokens=1" %%a in ('date /t') do set DoW=%%a ECHO Day-of-the-Week from DATE /T is %DoW% & PAUSE :: tedious way of getting the full Day (more elegant ways are possible!) if "%DoW%"=="Mon" set day=Monday if "%DoW%"=="Tue" set day=Tuesday if "%DoW%"=="Wed" set day=Wednesday if "%DoW%"=="Thu" set day=Thursday if "%DoW%"=="Fri" set day=Friday if "%DoW%"=="Sat" set day=Saturday if "%DoW%"=="Sun" set day=Sunday ECHO Today's (full name) day is
-
WSjrklein
AskWoody Lounger -
WSbigaldoc
AskWoody LoungerJune 1, 2003 at 11:25 am #681479It must be MY video, because I see some garbled characters in the post that, when I changed them to day worked just fine as put forth by John. I guess it must be me, since you didn’t mention a problem. Glad it does the trick!
Added: Maybe it my “interface” to the Lounge, because when I tried to type the % character, I got the same as my attachment, here in this post….. Anyone know why? (Evidently, two % signs causes a problem!?)
-
-
WSLeif
AskWoody LoungerJune 1, 2003 at 11:43 am #681482Not sure myself – there was a discussion about this many moons ago which I can’t immediately find, and more recently a similar oddity was discussed in this thread.
Edited to add:
Ah, it is beginning to come back to me…
% is OK
%d is OK
but % da gives you -
WSJohnGray
AskWoody Lounger -
WSunkamunka
AskWoody Lounger -
WSWyllyWylly
AskWoody Lounger -
WSunkamunka
AskWoody Lounger -
WSunkamunka
AskWoody Lounger -
WSWyllyWylly
AskWoody Lounger
-
-
WSunkamunka
AskWoody Lounger -
WSWyllyWylly
AskWoody Lounger -
WSWyllyWylly
AskWoody Lounger
-
-
-
WSjrklein
AskWoody LoungerJanuary 2, 2004 at 2:48 am #763281John:
I have been using this with great success till I upgraded to office 2003 which somehow affected windows XP. NOW I no longer get the day of the week. If I switch the regional settings to dddd, mm/dd/yyyy the batch works but it louse up microsoft money.
Is there a way of drawing the day of the week from say the long date format of windows to get the day of the week, or do you have a newer solution??
Thanks
Jerome -
WSJohnGray
AskWoody LoungerJanuary 2, 2004 at 6:54 am #763313Jerome
I don’t have Server 2003 so I can’t give you an immediate answer. I can derive the DoW from the date via a devious method, but having been off for nearly three weeks, my Inbox contains just under 1000 messages, at least 90% of which Spam, so I won’t get a chance to look today. But I will get back to you by/on Monday…
In the interim, can you please tell me what you get from DATE /T in a Command Prompt window, with the Short Date settings at the default values? Thanks. (I presume mm/dd/yyyy rather than DoW mm/dd/yyyy )
-
WSJohnGray
AskWoody LoungerJanuary 2, 2004 at 6:54 am #763314Jerome
I don’t have Server 2003 so I can’t give you an immediate answer. I can derive the DoW from the date via a devious method, but having been off for nearly three weeks, my Inbox contains just under 1000 messages, at least 90% of which Spam, so I won’t get a chance to look today. But I will get back to you by/on Monday…
In the interim, can you please tell me what you get from DATE /T in a Command Prompt window, with the Short Date settings at the default values? Thanks. (I presume mm/dd/yyyy rather than DoW mm/dd/yyyy )
-
WSJohnGray
AskWoody LoungerJanuary 2, 2004 at 9:03 am #763338Jerome
Heck, why should I redo the work since Ritchie Lawrence has already done it all?
(Go through “Batch Function Library” to “Date and Time Functions” to “DateToDoW”)
If you have any trouble with the three functions he’s calling, just let me know and I’ll combine them into a single chunk of BATch code for you.
-
WSjrklein
AskWoody LoungerJanuary 2, 2004 at 11:04 am #763350John:
I looked at the site, but it was too complex for me. I would very much appreciate it if you could combine it into the batch file that you wrote for me originally as it worked so well for me. Welcome back and Thanks.
Jerome
@echo offsetlocal
:: get today’s DoW, assuming US settings “DoW mm/dd/yyyy”
for /f “tokens=1” %%a in (‘date /t’) do set DoW=%%a
ECHO Day-of-the-Week from DATE /T is %DoW% & PAUSE:: tedious way of getting the full Day (more elegant ways are possible!)
if “%DoW%”==”Mon” set day=Monday
if “%DoW%”==”Tue” set day=Tuesday
if “%DoW%”==”Wed” set day=Wednesday
if “%DoW%”==”Thu” set day=Thursday
if “%DoW%”==”Fri” set day=Friday
if “%DoW%”==”Sat” set day=Saturday
if “%DoW%”==”Sun” set day=Sunday
ECHO Today’s (full name) day is -
WSJohnGray
AskWoody LoungerJanuary 3, 2004 at 11:04 am #763693Jerome
I have produced two versions for you, one using Ritchie Lawrence-type Functions, and the other using in-line code.
Since the Lounge is, at present, AGONISINGLY slow (and the clock is 1 hr 18 mins slow!), it would take too long to post them. Since the files are also a bit lengthy, I will try tomorrow to send you a Private Message with them in, otherwise, if it’s STILL slow, could you let me have an email address in a private message so that I can send them in ZIPped form on Monday. That would also get over the % d a problem we have…
-
WSunkamunka
AskWoody Lounger -
WSJohnGray
AskWoody LoungerJanuary 4, 2004 at 9:53 am #763759Unkamunka
We have engaged in extensive correspondence and testing – see the TXT attachment – good idea of yours, rather than getting it reformatted / % day’ed as part of the message.
If anyone is sufficiently interested to need an explanation of any part, please let me know! The “Stage 1” determination of year/month/day works regardless of operating system (viz. NT, 2000, XP, 2003) and of regional/international setting – XP certainly now drops the Day-of-the-Week for some countries, like UK. No, I don’t know why…
-
WSJohnGray
AskWoody LoungerJanuary 4, 2004 at 9:53 am #763760Unkamunka
We have engaged in extensive correspondence and testing – see the TXT attachment – good idea of yours, rather than getting it reformatted / % day’ed as part of the message.
If anyone is sufficiently interested to need an explanation of any part, please let me know! The “Stage 1” determination of year/month/day works regardless of operating system (viz. NT, 2000, XP, 2003) and of regional/international setting – XP certainly now drops the Day-of-the-Week for some countries, like UK. No, I don’t know why…
-
WSunkamunka
AskWoody Lounger -
WSjrklein
AskWoody LoungerOctober 30, 2004 at 11:30 am #893387Dear John
I love the batch files that you made up and use them every day to backup important directories in one fell swoop to have a quick backup for corruption and many days available of backups.
However I am trying to add a line for the outlook.pst and xcopy just seems to ignore it. Maybe xcopy cannot handle a long name. ? use xcopy32 or some other fix.
xcopy C:Documents and SettingsJerome R Klein MDLocal SettingsApplication DataMicrosoftOutlookoutlook4.pst “c:a -
WSjrklein
AskWoody LoungerOctober 30, 2004 at 11:30 am #893388Dear John
I love the batch files that you made up and use them every day to backup important directories in one fell swoop to have a quick backup for corruption and many days available of backups.
However I am trying to add a line for the outlook.pst and xcopy just seems to ignore it. Maybe xcopy cannot handle a long name. ? use xcopy32 or some other fix.
xcopy C:Documents and SettingsJerome R Klein MDLocal SettingsApplication DataMicrosoftOutlookoutlook4.pst “c:a -
joep517
AskWoody MVP -
WSjrklein
AskWoody Lounger -
WSJohnGray
AskWoody LoungerOctober 30, 2004 at 7:05 am #893531Jerome
I think Joe is right – if ever there’s a blank anywhere in a path, you MUST include the whole path in double-quotes. This applies equally to the source path as to the target path.
You should end up with something like
xcopy “C:Documents and SettingsJerome R Klein MDLocal SettingsApplication DataMicrosoftOutlookoutlook4.pst” “c:a
-
WSjrklein
AskWoody LoungerOctober 30, 2004 at 7:34 am #893533John:
I tried it again and added a pause as I wanted to see if there was an error message.
The quotes helped but now it seems that outlook when it is running and even after exiting unless you also get rid of a background outlook.exe blocks the file transfer unless outlook is unloaded in every which way. -
WSJohnGray
AskWoody LoungerOctober 30, 2004 at 9:16 am #893548Jerome
Yes, sorry – I had forgotten that it wouldn’t (and, indeed, shouldn’t) copy the file if it was open. When you close Outlook down you shouldn’t be left with an outstanding EXE file. Does this happen a lot? If so, I can give you a way to kill it, but you would have to ensure that you close Outlook down first…
John
-
WSjrklein
AskWoody LoungerOctober 30, 2004 at 11:33 am #893577John:
Today it seems to be working fine, yesterday when I was trying to get it to work it was doing it all the time, ie outlook really closes on close, go figure.
Does your way of closing mean I can put in a line before the xcopy in the batch file to close any extra instances of outlook that may be open?
Jerome -
WSJohnGray
AskWoody LoungerOctober 30, 2004 at 12:06 pm #893589Jerome
I don’t have a way to distinguish between a “real” unclosed version of Outlook, and one left lying around for some unknown reason. It would not necessarily be a good idea to “kill” the former (rather, one should close it down cleanly), but wouldn’t matter much about the latter (which probably should not be present, anyway).
As I said before, there should only be one copy of OUTLOOK.EXE in the Task manager -> processes list. Could you monitor this (click on the “Image Name”) column heading, and see how often you find two instances? Thanks!
John
-
WSJohnGray
AskWoody LoungerOctober 30, 2004 at 12:06 pm #893590Jerome
I don’t have a way to distinguish between a “real” unclosed version of Outlook, and one left lying around for some unknown reason. It would not necessarily be a good idea to “kill” the former (rather, one should close it down cleanly), but wouldn’t matter much about the latter (which probably should not be present, anyway).
As I said before, there should only be one copy of OUTLOOK.EXE in the Task manager -> processes list. Could you monitor this (click on the “Image Name”) column heading, and see how often you find two instances? Thanks!
John
-
WSjrklein
AskWoody LoungerOctober 30, 2004 at 11:33 am #893578John:
Today it seems to be working fine, yesterday when I was trying to get it to work it was doing it all the time, ie outlook really closes on close, go figure.
Does your way of closing mean I can put in a line before the xcopy in the batch file to close any extra instances of outlook that may be open?
Jerome -
WSJohnGray
AskWoody LoungerOctober 30, 2004 at 9:16 am #893549Jerome
Yes, sorry – I had forgotten that it wouldn’t (and, indeed, shouldn’t) copy the file if it was open. When you close Outlook down you shouldn’t be left with an outstanding EXE file. Does this happen a lot? If so, I can give you a way to kill it, but you would have to ensure that you close Outlook down first…
John
-
WSJohnGray
AskWoody LoungerOctober 30, 2004 at 7:05 am #893532Jerome
I think Joe is right – if ever there’s a blank anywhere in a path, you MUST include the whole path in double-quotes. This applies equally to the source path as to the target path.
You should end up with something like
xcopy “C:Documents and SettingsJerome R Klein MDLocal SettingsApplication DataMicrosoftOutlookoutlook4.pst” “c:a
-
WSjrklein
AskWoody Lounger -
joep517
AskWoody MVP -
WSJohnGray
AskWoody LoungerJanuary 3, 2004 at 11:04 am #763694Jerome
I have produced two versions for you, one using Ritchie Lawrence-type Functions, and the other using in-line code.
Since the Lounge is, at present, AGONISINGLY slow (and the clock is 1 hr 18 mins slow!), it would take too long to post them. Since the files are also a bit lengthy, I will try tomorrow to send you a Private Message with them in, otherwise, if it’s STILL slow, could you let me have an email address in a private message so that I can send them in ZIPped form on Monday. That would also get over the % d a problem we have…
-
-
WSjrklein
AskWoody LoungerJanuary 2, 2004 at 11:04 am #763351John:
I looked at the site, but it was too complex for me. I would very much appreciate it if you could combine it into the batch file that you wrote for me originally as it worked so well for me. Welcome back and Thanks.
Jerome
@echo offsetlocal
:: get today’s DoW, assuming US settings “DoW mm/dd/yyyy”
for /f “tokens=1” %%a in (‘date /t’) do set DoW=%%a
ECHO Day-of-the-Week from DATE /T is %DoW% & PAUSE:: tedious way of getting the full Day (more elegant ways are possible!)
if “%DoW%”==”Mon” set day=Monday
if “%DoW%”==”Tue” set day=Tuesday
if “%DoW%”==”Wed” set day=Wednesday
if “%DoW%”==”Thu” set day=Thursday
if “%DoW%”==”Fri” set day=Friday
if “%DoW%”==”Sat” set day=Saturday
if “%DoW%”==”Sun” set day=Sunday
ECHO Today’s (full name) day is
-
-
WSJohnGray
AskWoody LoungerJanuary 2, 2004 at 9:03 am #763339Jerome
Heck, why should I redo the work since Ritchie Lawrence has already done it all?
(Go through “Batch Function Library” to “Date and Time Functions” to “DateToDoW”)
If you have any trouble with the three functions he’s calling, just let me know and I’ll combine them into a single chunk of BATch code for you.
-
-
WSjrklein
AskWoody LoungerJanuary 2, 2004 at 2:48 am #763282John:
I have been using this with great success till I upgraded to office 2003 which somehow affected windows XP. NOW I no longer get the day of the week. If I switch the regional settings to dddd, mm/dd/yyyy the batch works but it louse up microsoft money.
Is there a way of drawing the day of the week from say the long date format of windows to get the day of the week, or do you have a newer solution??
Thanks
Jerome
-
-
WSbigaldoc
AskWoody Lounger -
WSTimOz
AskWoody LoungerJune 1, 2003 at 11:05 am #681478(Edited by TimOz on 01-Jun-03 20:05. Added PS)
I was tempted! And if John’s approach with the date command brings no joy, then AutoIt is a good canditate to help orchestrate the show. (On my sys it’s just dd-mm-yyyy, so I assumed it was the same elsewhere.)
PS Looks like we missed the boat. Guess we could argue that it would provide a more elegant solution.
-
Viewing 2 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Windows 11 Insider Preview Build 26100.4188 (24H2) released to Release Preview
by
joep517
2 hours, 36 minutes ago -
Microsoft is now putting quantum encryption in Windows builds
by
Alex5723
34 minutes ago -
Auto Time Zone Adjustment
by
wadeer
7 hours, 5 minutes ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
4 hours, 45 minutes ago -
Manage your browsing experience with Edge
by
Mary Branscombe
7 minutes ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
11 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
33 minutes ago -
Apps included with macOS
by
Will Fastie
11 minutes ago -
Xfinity home internet
by
MrJimPhelps
6 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
4 minutes ago -
Debian 12.11 released
by
Alex5723
1 day, 4 hours ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
1 day, 7 hours ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
11 hours, 21 minutes ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
3 hours, 45 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
2 days ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
1 day, 15 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
2 days, 3 hours ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
1 day, 19 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
1 day, 3 hours ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
5 hours, 16 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
2 days, 12 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
1 hour, 6 minutes ago -
Does windows update component store “self heal”?
by
Mike Cross
1 day, 23 hours ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
3 days, 2 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
1 day, 10 hours ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
23 hours, 32 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
3 days, 5 hours ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
3 days, 5 hours ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
18 minutes ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
3 days, 13 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.