forever0donotknowme Posted June 19, 2012 Posted June 19, 2012 hi my friends, really this is important topic i have some folder that contain many files with different extentions i want to do script that delete every files that are used befor one month = old and not open now for example, prefetch folder yes, in this case i will use file list array filedelete but i do not crrect script for my project that is used for deleting old prefetch files
BrewManNH Posted June 19, 2012 Posted June 19, 2012 Usse FileGetTime on each file and compare the date returned (last modified or last accessed date) with the current date and see if they're more than a month apart. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
forever0donotknowme Posted June 19, 2012 Author Posted June 19, 2012 BrewManNH my sir ,Do you think my intelligence and my experience and got to your level of practicali will try to make this hard script
Mechaflash Posted June 19, 2012 Posted June 19, 2012 Do what BrewManNH said and utilize _DateDiff() Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”
BrewManNH Posted June 19, 2012 Posted June 19, 2012 You'd have to reformat the values returned from the FileGetTime function to work with _DateDiff, but shouldn't be hard to do that. I'd also use _NowCalcDate instead of using _Now if using _DateDiff, because it returns the date in the format needed for _DateDiff. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
forever0donotknowme Posted June 19, 2012 Author Posted June 19, 2012 i will try today to write this script it will be ready tomorrow
AZJIO Posted June 20, 2012 Posted June 20, 2012 (edited) #include <Array.au3> #include <FileOperations.au3> Global $TimeDiff = 3600 * 24 * 30 $TimeCurrent = _NowCalc() $FileList = _FO_FileSearch(@WindowsDir, '*.tmp|*.log') ; $FileList = _FO_FileSearch(@WindowsDir, '*.tmp') _ArrayDisplay($FileList, 'File = *.tmp|*.log') $c = 0 For $i = 1 To $FileList[0] $t = FileGetTime($FileList[$i], 1) $sTime = $t[0] & '/' & $t[1] & '/' & $t[2] & ' ' & $t[3] & ':' & $t[4] & ':' & $t[5] If _DateDiff('s', $sTime, $TimeCurrent) > $TimeDiff Then $c += 1 $FileList[$c] = $FileList[$i] EndIf Next ReDim $FileList[$c + 1] $FileList[0] = $c _ArrayDisplay($FileList, '>month') If MsgBox(4, '???', 'FileDelete ?') = 6 Then $err = '' For $i = 1 To $FileList[0] If Not FileDelete($FileList[$i]) Then If Not (FileSetAttrib($FileList[$i], '-RST') And FileDelete($FileList[$i])) Then $err &= $FileList[$i] & @CRLF EndIf EndIf Next If $err Then MsgBox(0, 'Error', $err) EndIf Edited June 20, 2012 by AZJIO My other projects or all
forever0donotknowme Posted June 20, 2012 Author Posted June 20, 2012 (edited) #include <FileOperations.au3>error: error opening filecan you practice that script in prefetch folder for deleting all old files that not edited since last 20 days Edited June 20, 2012 by forever0donotknowme
AZJIO Posted June 20, 2012 Posted June 20, 2012 #include <FileOperations.au3>error: error opening file (again)last 20 daysGlobal $TimeDiff = 3600 * 24 * 20 My other projects or all
forever0donotknowme Posted June 20, 2012 Author Posted June 20, 2012 can you help me and give me full script for prefetch folder
Moderators JLogan3o13 Posted June 20, 2012 Moderators Posted June 20, 2012 forever0donotknowme, you've been around long enough to know better than to expect people to write your script for you. Put some effort into it, write something out based on the excellent suggestions you have received thus far, and then post your code if you run into problems. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
forever0donotknowme Posted June 20, 2012 Author Posted June 20, 2012 forever0donotknowme, you've been around long enough to know better than to expect people to write your script for you. Put some effort into it, write something out based on the excellent suggestions you have received thus far, and then post your code if you run into problems.you know my experience
JohnQSmith Posted June 20, 2012 Posted June 20, 2012 you know my experienceOh yeah... all talk, no action.i will try today to write this scriptit will be ready tomorrow Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".
forever0donotknowme Posted June 20, 2012 Author Posted June 20, 2012 (edited) Oh yeah... all talk, no action. i write some script but AZJIO guide me to another methodmy teachers are BrewManNH, albma23 , jlogan Edited June 20, 2012 by forever0donotknowme
forever0donotknowme Posted September 13, 2012 Author Posted September 13, 2012 AZJIO codei can not solve my problem in this topicplease can any one help me to give me script to delete old files that created more than one month in some folder that is existing in desktop
Somerset Posted September 13, 2012 Posted September 13, 2012 I don't think anyone wants to proverbially "give the gun to the chimp" and watch you shoot yourself and or others. Write the script a little at a time, until you got an understanding of how it works. You will continue to try to butter up others and hope they write it for you, but if someone gives you the script you learn nothing. Plan out the script before writing it. Read the help file, explore it and see what closely fits into your plans. Writing a script with no thought does you a disservice and causes only problems.
forever0donotknowme Posted September 13, 2012 Author Posted September 13, 2012 if you give me ready code, i will learn benefit for every line of code
forever0donotknowme Posted September 13, 2012 Author Posted September 13, 2012 i want script without message for delete attention<<< automatically delete all files that were created befor one month in prefetch folder
Moderators JLogan3o13 Posted September 13, 2012 Moderators Posted September 13, 2012 I believe the continued begging for "ready code" violates the spirit of the forum rules, especially the part about not being a "general nuisance" You know by now that we teach people to fish, rather than handing it to them, forever0donotknowme. You have to put some effort into it and post your own code, even if it doesn't work. Then, we will gladly assist you. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Recommended Posts