Vicki05
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_Mon th%%DT_Day %_%DT_Hour %%DT_Minut e%%DT_Seco nd%
if exist "%Target%" (
for %%a in ("%Target%") do set TargetNewName=%%~nxa_%Time Stamp%
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.
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_Mon
if exist "%Target%" (
for %%a in ("%Target%") do set TargetNewName=%%~nxa_%Time
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Vicki