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
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
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, 7 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
-
Office gets current release
by
Susan Bradley
46 minutes ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
6 hours, 9 minutes ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
2 hours, 53 minutes ago -
Stop the OneDrive defaults
by
CWBillow
6 hours, 58 minutes ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
16 hours, 53 minutes ago -
X Suspends Encrypted DMs
by
Alex5723
19 hours, 5 minutes ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
19 hours, 23 minutes ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
20 hours ago -
OpenAI model sabotages shutdown code
by
Cybertooth
20 hours, 37 minutes ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
8 hours, 47 minutes ago -
Enabling Secureboot
by
ITguy
15 hours, 47 minutes ago -
Windows hosting exposes additional bugs
by
Susan Bradley
1 day, 4 hours ago -
No more rounded corners??
by
CWBillow
1 day ago -
Android 15 and IPV6
by
Win7and10
14 hours, 5 minutes ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
1 day, 16 hours ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
1 day, 19 hours ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
1 day, 14 hours ago -
Windows Update orchestration platform to update all software
by
Alex5723
2 days, 2 hours ago -
May preview updates
by
Susan Bradley
1 day, 14 hours ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
1 day, 5 hours ago -
Just got this pop-up page while browsing
by
Alex5723
1 day, 19 hours ago -
KB5058379 / KB 5061768 Failures
by
crown
1 day, 16 hours ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
18 hours, 20 minutes ago -
At last – installation of 24H2
by
Botswana12
2 days, 18 hours ago -
MS-DEFCON 4: As good as it gets
by
Susan Bradley
15 hours, 7 minutes ago -
RyTuneX optimize Windows 10/11 tool
by
Alex5723
3 days, 6 hours ago -
Can I just update from Win11 22H2 to 23H2?
by
Dave Easley
1 day, 5 hours ago -
Limited account permission error related to Windows Update
by
gtd12345
3 days, 19 hours ago -
Another test post
by
gtd12345
3 days, 20 hours ago -
Connect to someone else computer
by
wadeer
3 days, 14 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.