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.

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.