Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: create a batch file with date as folder name  (Read 6566 times)

0 Members and 1 Guest are viewing this topic.

VaibhavVeralkar

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Windows XP
    create a batch file with date as folder name
    « on: November 19, 2014, 01:24:43 AM »
    Hey, i have created a batch file which copy the data of one folder into another. But after copying i want to give the particular date as a folder name. I am not able to. Please give your suggestions.

    This is my code.

    @echo off

    :: variables

    echo Backing up file

    set /P source=Enter source folder:

    set /P destination=Enter Destination folder:

    set listfile=xcopy /L

    set xcopy=xcopy /S/E/V/Q/F/H

    %listfile% %source% %destination%

    echo files will be copy press enter to proceed

    pause

    %xcopy% %source% %destination% %date%

    pause

    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: create a batch file with date as folder name
    « Reply #1 on: November 19, 2014, 01:37:00 AM »
    Multipost: http://stackoverflow.com/questions/27012028/create-a-batch-file-with-date-as-folder-name

    Does it matter to anyone that people multipost their questions?




    VaibhavVeralkar

      Topic Starter


      Rookie

      • Experience: Beginner
      • OS: Windows XP
      Re: create a batch file with date as folder name
      « Reply #2 on: November 19, 2014, 01:39:19 AM »
      i wanted my ans. this the reason why i have posted over here also. sorry

      Squashman



        Specialist
      • Thanked: 134
      • Experience: Experienced
      • OS: Other
      Re: create a batch file with date as folder name
      « Reply #3 on: November 19, 2014, 06:54:34 AM »
      The DATE /T command and the %DATE% variable all output with slashes.  So you will need to use a FOR /F command to strip out the day of the week and the slashes depending on what your DATE format is.

      You would then use the MD command to create a new directory for the destination.