Chaitanya Joshi
Chaitanya Joshi

Reputation: 11

Batch File to Copy files to another Folder, the new folder should get created with that instances Time-Stamping & Date-Stamping

I have an application which creates logs & if I don't take backup of those logs it will overwrite them, so I have created a script for backing up my files and putting them into a new folder, the name of the new folder is getting created with that instances time-stamping & date-stamping. Now the date & time format I have at my workplace is different than what I have mentioned in script so the folder is getting created with a gibberish name, so I want it to follow the same date & time format, the one I have at work i.e. Short Date: M/d/yyyy; Long Date: dddd, MMMM d, yyyy; Short Time: h:mm tt; Long Time: h:mm:ss tt

"  @echo off
set hh=%time:~-11,2%
set /a hh=%hh%+100
set hh=%hh:~1%
set dateseed=%date:~10,4%-%date:~4,2%-%date:~7,2%-%hh%-%time:~3,2%-%time:~6,2%

if not exist "D:\AHSM1_logs\%dateseed%" mkdir "D:\AHSM1_logs\%dateseed%"
cd "D:\Backup\%dateseed%"
move D:\"Program Files (x86)"\Entrust\"Enrollment Server for Web"\logs\cdalog.log-* D:\AHSM1_logs\%dateseed%   "

Upvotes: 1

Views: 52

Answers (1)

Gourav
Gourav

Reputation: 116

check the Solution by PA.

Check Solution 2

problem is setting date using %date% you can use WMIC to retrieve date and time

Upvotes: 1

Related Questions