How can I batch delete all files of a certain type in a folder newer than a certain date on Windows?

1

So Google Music decided to download about half of my uploaded music library to my local music library when I told it to download my purchased music, so now I have a bunch of MP3s I need to delete automatically.

Can I get any help here? I'm not so great with batch script.

Mr. November

Posted 2011-12-19T05:18:07.280

Reputation: 113

1Have to know which windows OS? I would address this as a selection problem like this by using "Search" , "Sort" , "Select" not having to batch anything. - - - - "Search" *.mp3 , there is every MP3. Add advanced search items like Date. Once you get a trimmed down enough "Search" then "Sort" use the Columns (size, Date modified date created, type) to "Sort", then Select the top item, hold the shift key, Select the last item needed to delete, and delete away. Search Sort Select. – Psycogeek – 2011-12-19T06:22:40.983

I had forgotten I could do all of that in search. I tinkered around a bit with it and eventually got the selection I needed. I'll mark Sathya's comment as the answer since it would definitely work with a bit of tinkering using the syntax page, probably a bit more efficiently and universally as well. – Mr. November – 2011-12-19T07:44:28.273

Answers

3

You can use forfiles

forfiles /p g:\music /d -30 /c "cmd /c del @file"

This will delete any file older than 30 days.

Read about forfiles syntax here

If it's not there in your system, download forfiles from MSFT's Reskit ftp

Sathyajith Bhat

Posted 2011-12-19T05:18:07.280

Reputation: 58 436

1

For another command script way to do this, using JP Software's TCC/LE, simply use date ranges and the del command:

del /[d2011-12-19] *.mp3

Yes, you can do the last 30 days, too:

del /[d-30] *.mp3

Further reading

JdeBP

Posted 2011-12-19T05:18:07.280

Reputation: 23 855