Vicki05
asked on
I have a batch file from here that checked if the folder existed and renamed it. Can someone help
I have this batch file from this site.
I tried running this but it does not seem to create the folder. I am trying to run this from local disk C: and I want to backup to local disk C: It does not seem to work.
Untitled.jpg
I tried running this but it does not seem to create the folder. I am trying to run this from local disk C: and I want to backup to local disk C: It does not seem to work.
Untitled.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One suggestion somekind off-topic... why don't you use robocopy?. Is a full featured copy/mirroring utility with several options that includes copy timstamp, owner, permissions, etc...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help again.
ASKER
Thanks for all the help.
ASKER
@echo off
setlocal enabledelayedexpansion
set Folder=C:\Temp\Foo
if not exist "%Folder%" goto Continue
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
for %%a in ("%Folder%") do set FolderName=%%~nxa
ECHO ren "%Folder%" "%FolderName%_%TimeStamp%"
if errorlevel 1 (
echo ERROR: could not rename "%Folder%" to "%FolderName%_%TimeStamp%"
pause
exit /b 1
)
:Continue