Quick links. Delete files on specific date Discussion forum for all Windows batch related topics. Delete files on specific date 1 Post by Ubaid » Sun Oct 05, pm Hi Friends, Please can any one help to create scrip to delete all files on define date.
Re: Delete files on specific date 2 Post by Squashman » Sun Oct 05, pm You will need to create a Windows scheduled task and have it run this command in a batch file. I blinked and looked. It displayed only files that were older than today and that had the TXT extension. I was floored. To learn how to remove them, I was ready for a long, drawn-out session. To remove the files, I saw only one extra bit of data. Something called Remove-Item seemed a pretty sensible name. I appended the last bit of code and read a bit further as the article described how to test it without doing anything dangerous by using the whatif parameter.
Staring and blinking at the screen of output, I scrolled up. It looked like something happened to the data. But, upon examining the folder, nothing happened. To actually do the damage, it asked me to remove the —whatif and run the cmdlet. I was ready for the worst.
This was my first time using PowerShell and I was untrusting. So, repeat process, install PowerShell 1. I tested the process, and the results were the same. Now I had to figure out how to schedule this. Oh, this was like DOS. Instead of running cmd. PS1, and set up a scheduled task.
I was on site for barely 20 minutes for a two-hour minimum billable call. Arno Jansen Arno Jansen 2 2 silver badges 2 2 bronze badges. Same error as in other answers including the accepted one. It only matches files with. The OP never said anything about requiring. AnT: Are you sure? This MS documentation page - technet. Background on the 5 wildcards in Windows: blogs. Show 1 more comment.
Community Bot 1 1 1 silver badge. James e. James k 39 39 gold badges silver badges bronze badges. And the only question I have: how to add multiple mask for example ".
Viktor Ka Viktor Ka 3 3 silver badges 5 5 bronze badges. This even works in Windows Server and above and Windows 7. First, the tables: Days since UTC for each year including leap days.
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Year with days: 0 31 59 90 Year with days: 0 31 60 91 Converting a date to number of seconds since is quite easy using those tables. Attention please! The file can be deleted if seconds rem value is lower than the value calculated above. Further the batch code below is optimized for 24 hours time format. Mofi Mofi Copy this code and save it as DelOldFiles. WriteLine f1 f1. Paris Paris 89 1 1 silver badge 1 1 bronze badge.
Use forfiles. There are different versions. Early ones use unix style parameters. Aidan Ewen Aidan Ewen Kibbee it's not the same answer the syntax is different. This was a geniune attempt to help. Knowning very little of the windows command line, I spent hours of frustration getting this to work. The key bits of info for me were the fact that there's different versions with different syntax , and that I needed to removed the spaces. Neither of these things were included in the orginal answer.
I would have commented on the answer but I don't have the privileges — Aidan Ewen. CreateObject "Scripting. SubFolders ; for ;! Graham Laight Graham Laight 4, 3 3 gold badges 28 28 silver badges 26 26 bronze badges.
It can be done in less than 10 lines of coding! Sting Sting 2 2 silver badges 11 11 bronze badges. Io-oI 2, 3 3 gold badges 17 17 silver badges 25 25 bronze badges. Lectrode Lectrode 1 1 gold badge 2 2 silver badges 12 12 bronze badges. Shawn Pauliszyn Shawn Pauliszyn 6 6 bronze badges. The existing second-most-upvoted answer also espouses RoboCopy. Granted, you use somewhat different options, but it is close to the existing answer.
This has post has a new content--moving files to the recycle bin. This has not yet been been proposed with Robocopy and it fully answers the original post using a built-in single-line command. Hey I'm still new here--give me a break; — Shawn Pauliszyn. In other words - don't try to invent this, unless you really can't use the third party tools.
Paulius Paulius 5, 7 7 gold badges 41 41 silver badges 47 47 bronze badges. Goran B. Miguel Carrillo Miguel Carrillo 4 4 silver badges 6 6 bronze badges.
Snickbrack Snickbrack 2 2 gold badges 14 14 silver badges 48 48 bronze badges. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked See more linked questions. Related Hot Network Questions.
0コメント