Hello,
Got another batch file question.
I think I`m close but I`m overlooking something.
I have some logging that will get the date of today when I log off.
But now if I log off twice the file won`t rename, filename already exists.
So I came with a script to just add a number behind the file if it already exists.
And here is the problem it doesn`t work but I can`t seems to find out why it won`t work.
Hopefully an extra pair of eyes can help me out
This is what I got so far:
@ echo off
set jaar=%date:~9,4%
set maand=%date:~6,2%
set dag=%date:~3,2%
set restartvar=1
if exist "D:\test\HardwareMonitoring %jaar%-%maand%-%dag%.txt" (
goto restart
) else (
goto shutdown
)
:restart
if exist "D:\test\HardwareMonitoring %jaar%-%maand%-%dag% [%restartvar%].txt"(
set /A restartvar=%restartvar%+1
goto restart
) else (
ren "D:\test\HardwareMonitoring.hml" "HardwareMonitoring %jaar%-%maand%-%dag% [%restart%].txt"
)
:shutdown
ren "D:\test\HardwareMonitoring.hml" "HardwareMonitoring %jaar%-%maand%-%dag%.txt"
The first file that is in that folder just renames so no problems there.
It seems there is a problem in the restart loop.
Hope that you can find the solution to my problem
Got another batch file question.
I think I`m close but I`m overlooking something.
I have some logging that will get the date of today when I log off.
But now if I log off twice the file won`t rename, filename already exists.
So I came with a script to just add a number behind the file if it already exists.
And here is the problem it doesn`t work but I can`t seems to find out why it won`t work.
Hopefully an extra pair of eyes can help me out

This is what I got so far:
@ echo off
set jaar=%date:~9,4%
set maand=%date:~6,2%
set dag=%date:~3,2%
set restartvar=1
if exist "D:\test\HardwareMonitoring %jaar%-%maand%-%dag%.txt" (
goto restart
) else (
goto shutdown
)
:restart
if exist "D:\test\HardwareMonitoring %jaar%-%maand%-%dag% [%restartvar%].txt"(
set /A restartvar=%restartvar%+1
goto restart
) else (
ren "D:\test\HardwareMonitoring.hml" "HardwareMonitoring %jaar%-%maand%-%dag% [%restart%].txt"
)
:shutdown
ren "D:\test\HardwareMonitoring.hml" "HardwareMonitoring %jaar%-%maand%-%dag%.txt"
The first file that is in that folder just renames so no problems there.
It seems there is a problem in the restart loop.
Hope that you can find the solution to my problem
My Computer
- Computer type
- PC/Desktop
- Computer Manufacturer/Model Number
- Custom build
- OS
- Windows 7 Ultimate Edition (64-bit) Service Pack 1
- CPU
- Intel(R) Core(TM) i7 CPU 4820K @ 3.70GHz
- Motherboard
- Asus X79 Deluxe
- Memory
- 16 GB
- Graphics Card(s)
- NVIDIA GeForce GTX 760
- Sound Card
- None
- Monitor(s) Displays
- SyncMaster P2270HD
- Screen Resolution
- 1920 x 1080
- Hard Drives
- C:\ 128 GB SSD
D:\ 2 TB HDD
- PSU
- 550 Watt
- Cooling
- Water Cooling
- Keyboard
- Microsoft Natural Ergonomic Keyboard 4000
- Mouse
- 8 Button Wheel Mouse Present
- Internet Speed
- Low
- Antivirus
- Microsoft security essentials
- Browser
- IE11