Using BAT to copy directories.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
crazygamer24151
Posts: 1
Joined: 02 Oct 2021 17:04

Using BAT to copy directories.

#1 Post by crazygamer24151 » 02 Oct 2021 17:15

I am wanting to have a .bat file make a copy of 3 directories. I want it to make a directory with the day's date in and copy the 3 other directories into it. I want all 3 directories to keep their separate file trees. How do I do this?

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Using BAT to copy directories.

#2 Post by aGerman » 03 Oct 2021 08:42

Something about like that

Code: Select all

@echo off &setlocal
for /f %%i in ('WMIC OS Get LocalDateTime /value') do for /f %%j in ("%%i") do set "%%j"
robocopy "dir1" "%LocalDateTime:~0,8%\dir1" /e /r:0 /w:0
robocopy "dir2" "%LocalDateTime:~0,8%\dir2" /e /r:0 /w:0
robocopy "dir3" "%LocalDateTime:~0,8%\dir3" /e /r:0 /w:0
Steffen

Post Reply