Dos script delete files by date




















We can't always guarantee that the perfect solution to your specific problem will be waiting for you. If you ask your own question - our Certified Experts will team up with you to help you get the answers you need. Who are the certified experts? How quickly will I get my solution? We can't guarantee quick solutions - Experts Exchange isn't a help desk.

We're a community of IT professionals committed to sharing knowledge. Our experts volunteer their time to help other people in the technology industry learn and succeed. Plans and Pricing. Contact Us. Certified Expert Program. Asked 13 years, 1 month ago.

Active 2 years, 11 months ago. Viewed k times. A new method based in a. EXE commands only has been posted here: stackoverflow. I don't agree this is a duplicate question Add a comment. Active Oldest Votes. CreateObject "Scripting. CreateObject "WScript. Vincent Robert Vincent Robert Great solution, exactly what I need — LPChip. Edit: I figured it out. My solution works if you either have a touch utility on your system which I do or can afford to temporarily change system date using date command which is probably not the case, but who knows Here's the idea: In the target directory, create a signal file with a unique name , and with timestamp equal to your deletion threshold time.

This seems like an incredibly risky approach compared to the other answers here. Dan If you are referring to the possibility that something will mess with the signal file, it can be guarded against by splitting 2 into two stages: 2. Otherwise, abort. Anyway, this solution is a kludge, of course. I was just thinking if you accidentally ordered the files incorrectly you might delete thousands of files before reaching the signal file that you didn't want to delete.

I don't like the idea of having a signal file vs. I also don't quite understand how your approach deals with subdirectories not sure if that was a requirement for OP, but it is for me.

Dan IMO, ordering the files incorrectly is no greater danger than mistyping the cutoff date, with same result. PS1, and set up a scheduled task. I was on site for barely 20 minutes for a two-hour minimum billable call. I was also on the road early and beat rush hour traffic on a Friday. Yes, I love using PowerShell. Even if you, too, are that field tech with no time on your hands.

I invite you to follow the Scripting Guys on Twitter and Facebook. If you have any questions, send email to them at scripter microsoft. See you tomorrow. Comments are closed. Scripting Forums. PowerShell Forums. PowerShell on TechCommunity. Erase files based on date by using PowerShell Dr Scripto. June 28th, I used to use tree. Is there something Doctor Scripto June 28, I have a simple but irritating task each day around lunch Doctor Scripto June 29, NET Core.



0コメント

  • 1000 / 1000