Solved Batch file counting dates compare

Sygron

New member
Member
Local time
3:38 AM
Messages
59
Hello everyone,

Don`t know for sure if this is the correct place to put this question just tell me where else ;)

I have a problem with a batch file.
I made a file that renames files to the date when I log off.
But I also want to let it clean files that are older than a month.
I thought I was able to make it happen just take the month minus 1 and compare names.

Although seems I can`t do a minus one in batch, searched alot over the internet.
Does anyone know a different way so I can compare file names to delete old logs?

Hope to hear something soon.
 

My Computer My Computer

At a glance

Windows 7 Ultimate Edition (64-bit) Service P...Intel(R) Core(TM) i7 CPU 4820K @ 3.70GHz16 GBNVIDIA GeForce GTX 760
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

My Computer My Computer

At a glance

Windows 10 Pro X64Intel Quad Core i7-4770 @ 3.4Ghz16.0GB PC3-12800 DDR3 SDRAM 1600 MHzIntel Integrated HD Graphics
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
Thx for the help just the site I needed.
Now I just solved my problem in a different way with forfiles.
Works alot easier as it already has a date function in it.

Now I clean the files as followed:
forfiles /p "D:\Logging" /s /m *.txt /c "cmd /c Del @path" /d -30

But again thx for the help will come in handy in the future.
 
Last edited:

My Computer My Computer

At a glance

Windows 7 Ultimate Edition (64-bit) Service P...Intel(R) Core(TM) i7 CPU 4820K @ 3.70GHz16 GBNVIDIA GeForce GTX 760
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
Very cool. I have never heard of forfiles before and I've been doing this for a long time. The /d is a great parameter.

Thanks for the info.

Edit: Ah, I see forfiles was introduced in Windows Vista. Does not exist in XP or earlier.
 

My Computer My Computer

At a glance

Windows 10 Pro X64Intel Quad Core i7-4770 @ 3.4Ghz16.0GB PC3-12800 DDR3 SDRAM 1600 MHzIntel Integrated HD Graphics
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
Back
Top