I want to delete files and folders older than xx days
I have found this code:
forfiles -p "C:\what\ever" -s -m *.* /D -<number of days> /C "cmd /c del @path"
But does that delete folders as well?
I also found other code that said it was for Powershell
I've seen Powershell a few times but havent ever looked into
There are 2 versions of the code V2 and V3
The code looks alien to me! Not come across before
Is Powershell better than DOS?
I opened Powershell and typed Dir
It took about 15 seconds to respond and give any output
Am I doing something wrong?
Thanks
OM
How to delete files older than x days + what's Powershell?
Moderator: DosItHelp
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: How to delete files older than x days + what's Powershel
That code will only delete files, since the delete command doesn't delete folders. If you want to delete folders, use rd instead.
As for PowerShell, it's similar to batch, but can do different things. It's technically a completely different language, and it definitely has its uses. As to whether or not it's better, that's pretty objective. (Although asking this question on somewhere like Stack Overflow would get a pretty overwhelming "yes" response, but this forum is almost exclusively for batch (give or take a little vbscript).) Personally, I recommend batch for everything except doing math with numbers larger than 2^31 or decimals (batch numbers are signed 32-bit integers), or if you need to interact with GUIs (the only PowerShell script I've ever written was to open, move, and resize a bunch of graphs for work).
As for PowerShell, it's similar to batch, but can do different things. It's technically a completely different language, and it definitely has its uses. As to whether or not it's better, that's pretty objective. (Although asking this question on somewhere like Stack Overflow would get a pretty overwhelming "yes" response, but this forum is almost exclusively for batch (give or take a little vbscript).) Personally, I recommend batch for everything except doing math with numbers larger than 2^31 or decimals (batch numbers are signed 32-bit integers), or if you need to interact with GUIs (the only PowerShell script I've ever written was to open, move, and resize a bunch of graphs for work).