Dear All,

for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do set fdate=%%a%%b%%c
for /f "tokens=1,2,3,4,5 delims=: " %%a in ('time /t') do set ftime=%%a%%b%%c%%d%%e
exp userid=HR/HR@dummy file=C:\BACKUP\backup%fdate%%ftime%.dmp log=C:\BACKUP\backup%fdate%%ftime%.log

This scripts works fine but my requirement is when this script run it should make a folder its name should be current hour. i.e

if time is 5 o clock the the name of folder should be 5 and when hour is 6 then the name of the folder should be 6.

Any idea how to achieve this.

Edited by Naveed_786: n/a

6 Years
Discussion Span
Last Post by PhilliePhan

Hi Naveed,

A few yeas ago I made a little batch tool to remove a particular malware and I wanted to first back up the registry before the tool deleted keys.

I exported the reg backup into a folder with the date and time of the backup. It wasn't particularly sophisticated, but it went something like this:

for /f "tokens=2-4 delims=/- " %%A in ('date/t') do set varA=%%A-%%B-%%C
for /f "tokens=1* delims=:-" %%A in ('time/t') do set varB=%%A%%B

mkdir "%systemdrive%\PhilliePhan Registry Backup %varA% %varB%\"
cd %systemdrive%\PhilliePhan Registry Backup %varA% %varB%\
regedit /e Backup.reg

You ought to be able to mkdir with whatever variable you want as the name.

I think the final result was a bit more simplified, but I can't recall it - this is how I plotted it out in my head when I conceived it.

Hope it helps.

PP :)

Edited by PhilliePhan: Can't remember exactly how I did this

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.