• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

Create a directory with date and copy data using Robocopy

Hi all, I wonder if you can help. I have created a robocopy script in which I can copy my data from my usb drive to my laptop and it works. I have also told it to create a folder with the current date and place the data on it, however, it creates de folder but does not put the data on the created folder but on the location where the bat file is. Can someone help please?

Also it sets the day on the folder like this 21042010, could this be changed to 21-04-2010?

 The script I have created is the following:

@echo off

set dd=%date:~0,2%
set mm=%date:~3,2%
set yy=%date:~6,4%

md %dd%%mm%%yy%
cd %yy%%mm%%dd%

RoboCopy.exe E:\\ C:\USB-DRIVE *.* /e /zb /eta

Many thanks in advance.
0
cw-it
Asked:
cw-it
  • 2
1 Solution
 
Johnner_dkCommented:
@echo off

set dd=%date:~0,2%
set mm=%date:~3,2%
set yy=%date:~6,4%

md %dd%-%mm%-%yy%
cd %yy%-%mm%-%dd%
0
 
cw-itAuthor Commented:
Thanks Johnner, now it creates a folder the way I wanted [ie. 21-04-2010]. However, it creates the folder empty on the desktop, which is where I have the bat file, however, how can I do so that it creates the folder and copy the files to that folder. The folder that it creates currently is empty and not in the right location. It should be created on C:\USB-DRIVE and all the files should have been copy to that folder.
0
 
cw-itAuthor Commented:
After digging for a while I managed to find the solution.

@ECHO OFF

IF "%1" == "" GOTO CURRENT

%1:

:CURRENT
CD\
CLS
CD C:\USB-DRIVE\

set dd=%date:~0,2%
set mm=%date:~3,2%
set yy=%date:~6,4%

RoboCopy.exe E:\\ C:\USB-DRIVE\%dd%-%mm%-%yy% *.* /e /zb /eta

Thanks for your help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now