Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Batch file counting dates compare

08 Jun 2014   #1
Sygron

Windows 7 Ultimate Edition (64-bit) Service Pack 1
 
 
Batch file counting dates compare

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 System SpecsSystem Spec
.
08 Jun 2014   #2
Ztruker

Windows 10 Pro X64
 
 

Here is a good, short tutorial on basic math in Batch files: Batch files - Math
My System SpecsSystem Spec
09 Jun 2014   #3
Sygron

Windows 7 Ultimate Edition (64-bit) Service Pack 1
 
 

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.
My System SpecsSystem Spec
.

09 Jun 2014   #4
Ztruker

Windows 10 Pro X64
 
 

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 System SpecsSystem Spec
Reply

 Batch file counting dates compare




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
I need a batch file to open a random file within a certain folder/path
I want a batch to select and open a random link file in a folder i have. All the links are music videos I like to listen to, and I kind of want to just have an option for 'surprise me!'. I can change the file names if I have to, and I have a basic batch file ability. I know the simple commands,...
General Discussion
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
Need duplicate file finder, compare and delete
Hello, I have a hard drive that has all sorts of archives of archives in it. So many, that I think I have duplicates of many files. They are not compressed or anything. I would like a program to go through the HD and pick out the duplicates and preferrably, automatically delete the oldest...
Software
File folders and names with BC/AD dates
I'm trying to create a set of directories that show art from various eras. I want them to appear in chronological order. Thus, I want the BC years to proceed backward to 0 and then forward again after AD. I've tried putting negative numbers in front of the dates but this doesn't seem to help. Any...
General Discussion
How to create a batch file that will move files based on the file type
How to create a batch file that will move files based on the file type? My Requirement : I need a batch file to copy all .doc files in all my HardDisk to a removable disk say (Z: drive) . Can anyone make it possible using a batch file?Please...Its urgent...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 20:53.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App