Can somebody tell me the best way to delete a series of files between April 1, 2014 and April 17, 2014 on Windows server 2003 command line
            Asked
            
        
        
            Active
            
        
            Viewed 908 times
        
    -1
            
            
        - 
                    Have you tried anything (including a search here) in order to do so? This is not a "Here are my specs. Please write the code. I'll stop back later to pick it up." site. – Ken White May 14 '14 at 22:51
- 
                    Tried doing a for files and for /f – ondrovic May 14 '14 at 23:04
- 
                    2Try doing a search for (including the brackets) `[batch-file] delete files older`. The very first hit is [Batch file to delete files older than N days](http://stackoverflow.com/q/51054), which gives you half of the answer. It should be pretty easy then to modify to add the other half (or at least give you a place to start trying to do so). – Ken White May 14 '14 at 23:08
1 Answers
1
            This PowerShell oneliner will do the trick. You can remove the back-ticks and put the code all on one line if you want.
Get-ChildItem C:\data\*.* | `
Where-Object {$_.lastwritetime -gt '4/1/14' -AND $_.lastwritetime -lt '4/17/14'} | `
Remove-Item
I found a shorter version of the script here. I prefer to use the full Powershell cmdlet names though.
 
    
    
        Rich Wellman
        
- 36
- 1
