Jump to content

Recommended Posts

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

Link to comment
Share on other sites

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 Gude
How 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

Link to comment
Share on other sites

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.”

 

Link to comment
Share on other sites

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 Gude
How 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

Link to comment
Share on other sites

#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 by AZJIO
Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 months later...

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.

Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...