Link to home
Start Free TrialLog in
Avatar of Vicki05
Vicki05Flag for United States of America

asked on

Need to Copy files and folders in a batch file

Hi

1. I got this script from here. I needed more help. If I want to just copy the files overwrite the files in the folder and not put a time stamp on the folder how do I do that using this batch file?

@echo off
setlocal enabledelayedexpansion
set Source=%~d0\help
set Target=C:\test1\test 2

REM The next line sets the following DateTime variables: DT_Day, DT_DayOfWeek, DT_Hour, DT_Minute, DT_Month, DT_Quarter, DT_Second, DT_WeekInMonth, DT_Year
for /f "delims=" %%a in ('wmic.exe Path Win32_LocalTime GET * /value') do (for /f "delims=" %%b in ("%%a") do set DT_%%b)
for %%a in (DT_Month DT_Day DT_Hour DT_Minute DT_Second) do (if !%%a! LSS 10 set %%a=0!%%a!)
set Timestamp=%DT_Year%%DT_Month%%DT_Day%_%DT_Hour%%DT_Minute%%DT_Second%

if exist "%Target%" (
      for %%a in ("%Target%") do set TargetNewName=%%~nxa_%TimeStamp%
      attrib.exe -R "%Target%" /s /d
      ren "%Target%" "!TargetNewName!"
      echo Renamed "%Target%" to "!TargetNewName!"
      robocopy.exe "%Source%" "%Target%" /e /r:0 /a-:R
)



2. I want to copy Folder and its content from a CD to a local disk c: and remove the read only permissions.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vicki05

ASKER

Thanks a lot for your help oBdA. Your solution works.

Vicki