DEL oldfiles

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
xiro
Posts: 34
Joined: 21 May 2014 00:17

DEL oldfiles

#1 Post by xiro » 12 Feb 2023 19:16

Guys I just want to ask how you delete files older than 14 days or three days or set a number of days for the file to be deleted because Del command has only the following attributes?


Image



any ideas, suggestions?

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: DEL oldfiles

#2 Post by ShadowThief » 13 Feb 2023 00:36

That's what the forfiles command is for.

Code: Select all

forfiles /p "C:\what\ever" /s /m *.* /D -<number of days> /C "cmd /c del @path"
See https://stackoverflow.com/questions/510 ... han-n-days for more examples.

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: DEL oldfiles

#3 Post by xiro » 13 Feb 2023 03:09

ShadowThief wrote:
13 Feb 2023 00:36
That's what the forfiles command is for.

Code: Select all

forfiles /p "C:\what\ever" /s /m *.* /D -<number of days> /C "cmd /c del @path"
See https://stackoverflow.com/questions/510 ... han-n-days for more examples.
Ah so that the reason why no del attribute for for a specific date of file to be deleted. Any way to make forfiles faster?

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: DEL oldfiles

#4 Post by ShadowThief » 13 Feb 2023 19:09

Delete fewer files?

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: DEL oldfiles

#5 Post by xiro » 13 Feb 2023 19:43

xiro wrote:
13 Feb 2023 03:09
ShadowThief wrote:
13 Feb 2023 00:36
That's what the forfiles command is for.

Code: Select all

forfiles /p "C:\what\ever" /s /m *.* /D -<number of days> /C "cmd /c del @path"
See https://stackoverflow.com/questions/510 ... han-n-days for more examples.
Ah so that the reason why no del attribute for a specific date of file to be deleted. Any way to make forfiles faster?
Thank you so much for the forfiles command that you share but is their a way or other command or attribute to make the deletion faster I am deleting multiple folders a lot of time and they are sized up to 60 GB or more aside from doing it manually any other way forfiles is fast for individual items but with folders containing multiple files with the large size the delete process took more than overnight for I have tested this.

I hope anyone here tried another alternative :?:

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: DEL oldfiles

#6 Post by xiro » 13 Feb 2023 19:44

ShadowThief wrote:
13 Feb 2023 19:09
Delete fewer files?
Need to delete it on bulk so the next day the external hdd is available for another set of backup :)

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: DEL oldfiles

#7 Post by ShadowThief » 13 Feb 2023 21:22

Would it be faster to move all the files that are younger than 3 days old somewhere else and then delete the folders entirely?

Barring that, BestBuy is currently selling 18 TB external hard drives for $290, which is cheaper than they're usually going for. It may be worth upgrading your storage so that you have more time to let the command run.

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: DEL oldfiles

#8 Post by xiro » 14 Feb 2023 19:29

ShadowThief wrote:
13 Feb 2023 21:22
Would it be faster to move all the files that are younger than 3 days old somewhere else and then delete the folders entirely?

Barring that, BestBuy is currently selling 18 TB external hard drives for $290, which is cheaper than they're usually going for. It may be worth upgrading your storage so that you have more time to let the command run.
if move that's robocopy right with the attribute /maxage:3 right? I prefer to delete so I was really looking for an option or workaround for this but thank for your suggestions anyway :)

ohenryx2
Posts: 5
Joined: 08 Apr 2023 14:16

Re: DEL oldfiles

#9 Post by ohenryx2 » 08 Apr 2023 14:20

This is one of those situations where I would use the unix like tools found in Cygwin. There is an excellent discussion of this exact topic "How to find and delete files older than specific days in unix?" at

https://unix.stackexchange.com/question ... ys-in-unix

DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

Re: DEL oldfiles

#10 Post by DOSadnie » 24 Apr 2023 16:06

How about using Everything?

It will probably allow for filtering of files based on some regular expression or some inner feature which could be saved thus accessed with just ~3 clicks later on

And on top of an AutoHotkey file would serve as a script doing this automatically - and also make it run one way or another on system startup

koko
Posts: 38
Joined: 13 Oct 2016 00:40

Re: DEL oldfiles

#11 Post by koko » 25 Apr 2023 01:02

There's a utility called byenow from the dev of Bvckup that is faster (some bechmarks of byenow/del/rmdir/robocopy appear on the page). May want to test it.

Edit: forgot it takes directories as inputs only.

Image

Post Reply