Windows 7 Need to Convert Windows XP Batch File to Windows 7

Discussion in 'Programming and Scripting' started by Grayson Lee, Feb 9, 2010.

  1. Grayson Lee

    Grayson Lee New Member

    Joined:
    Feb 9, 2010
    Messages:
    2
    Likes Received:
    0
    Hello:

    This is my first time posting here. Thanks in advance for any assistance.

    I have a batch file that worked faithfully in Windows XP. I wish to update the code to work in Windows 7 Ultimate (64-bit).

    The code creates a folder with a date in its name. the code is as follows:

    @echo off
    cls
    :: Create environment variables with today's date values.
    setlocal
    for /f "tokens=1-4 delims=/ " %%i in ('date /t') do (
    set Day=%%i
    set MM=%%j
    set DD=%%k
    set YYYY=%%l
    )
    :: Create backup folder with today's date and move disk image to backup folder.
    md D:\Backup\-- F-BU

    In Windows XP, a folder with path D:\Backup\2010-02-09 F-BU would be created.

    However, when I run the code in Windows 7, I get a folder with path and name as follows: D:\Backup\-- F-BU

    If anyone could please help me out, it would be greatly appreciated.

    Thanks,

    Grayson
     
  2. sayyedj

    sayyedj New Member

    Joined:
    Mar 3, 2010
    Messages:
    4
    Likes Received:
    0
    I think your script had something wrong. You can amend the script as below . There are two methods.

    You can use this way ----
    @echo off
    cls
    :: Create environment variables with today's date values.
    setlocal
    for /f "tokens=1-4 delims=/ " %%i in ('date /t') do (
    set DD=%%i
    set MM=%%j
    set YYYY=%%k
    )
    :: Create backup folder with today's date and move disk image to backup folder.
    md D:\Backup\%YYYY%-%MM%-%DD%-F-BU
    --------------------------------------------------------------------------------------------------
    Or

    for /f "tokens=1-4 delims=/ " %%i in ('date /t') do ( md D:\Backup\%%i-%%j-%%k-F-BU )
     

Share This Page

Loading...