Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    NY, NY, USA
    Posts
    654
    Thanks
    10
    Thanked 0 Times in 0 Posts

    XCOPY batch file that takes its name from weekday (Windows XP)

    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

  2. #2
    5 Star Lounger
    Join Date
    Dec 2002
    Location
    Perth, Western Australia, Australia
    Posts
    730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XCOPY batch file that takes its name from weekday (Windows XP)

    In 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.
    <font face="Comic Sans MS" color="blue">TimOz</font>
    <img src=/S/flags/Finland.gif border=0 alt=Finland width=30 height=18> <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  3. #3
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: XCOPY batch file that takes its name from weekday (Windows XP)

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

    <pre>@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
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  4. #4
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: XCOPY batch file that takes its name from week

    And Tim, don't miss an opportunity to recruit another Lounger to AutoIt. Even though I'm still a novice with AutoIt, there are "special variables" built-in to the software, such as " A_WDAY " and a host of others.

  5. #5
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    NY, NY, USA
    Posts
    654
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Re: XCOPY batch file that takes its name from weekday (Windows XP)

    John:
    Wow this works perectly. Just what I wanted. Looks kind of complex to put together.
    Thanks a million
    Jerome

  6. #6
    5 Star Lounger
    Join Date
    Dec 2002
    Location
    Perth, Western Australia, Australia
    Posts
    730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XCOPY batch file that takes its name from week

    <P ID="edit" class=small>(Edited by TimOz on 01-Jun-03 20:05. Added PS)</P> <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15> 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. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    <font face="Comic Sans MS" color="blue">TimOz</font>
    <img src=/S/flags/Finland.gif border=0 alt=Finland width=30 height=18> <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  7. #7
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: XCOPY batch file that takes its name from week

    It must be MY video, because I see some garbled characters in the post that, when I changed them to <percent sign>day<percent sign> 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!?)

  8. #8
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XCOPY batch file that takes its name from weekday (Windows XP)

    Not 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

  9. #9
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: XCOPY batch file that takes its name from weekday (Windows XP)

    So the question is: Why? and to what purpose? [Oh dear, that's two questions!]

    I'm glad Jerome got what he wanted; it's pretty straightforward doing this in a BATch file. Maybe we should have a forum devoted to Scripting? <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  10. #10
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    NY, NY, USA
    Posts
    654
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Re: XCOPY batch file that takes its name from weekday (Windows XP)

    John:
    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

  11. #11
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XCOPY batch file that takes its name from week

    <hr>Maybe we should have a forum devoted to Scripting? <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29><hr>
    Perhaps - in the last 7 months - you've now found the Web Design, Coding & Scripting Board? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Gre

  12. #12
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: XCOPY batch file that takes its name from weekday (Windows XP)

    Jerome

    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 )
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  13. #13
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XCOPY batch file that takes its name from week

    When I read the title of that board, I think of web-related scripting, not batch files. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    -Mark

  14. #14
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XCOPY batch file that takes its name from week

    So did I - the first few times I looked at it. Isn't this a bit like our discussion of whether a Win2K Server issue should be on the Win2K Board or the Servers Board? How about renaming it Coding, Scripting and Web Design? <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Gre

  15. #15
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: XCOPY batch file that takes its name from weekday (Windows XP)

    Jerome

    Heck, why should I redo the work since Ritchie Lawrence has already done it all? <img src=/S/grin.gif border=0 alt=grin width=15 height=15> (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.
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •