Jump to content

Recommended Posts

Posted

hi,

I need help in deleting files. files are called this way: reg_YYYYMMDDHHMMSS.txt I need to delete files every 6 hours - the past 5 hours should be deleted.

I thougth of two options, to convert the numbers: HHMMSS to 21600 (every 6 hours: 6*60*60), but that will only give me a solution on when to delete the files....but not the algorithem to delete the ones with HH lower then the current hour.

if the hour now is 23,files with hours: 22,21,20,19,18 needs to be deleted. my problem is with the 24 clock. 000000 is midnigth I can't use (-) here because i will get a negetive values.

pls advise me.

THanks,

Posted

#include <date.au3>

$filename = "reg_YYYYMMDDHHMMSS.txt"

$YYYY = StringMid($filename, 5,4)
$MM = StringMid($filename, 9,2)
$DD = StringMid($filename, 11,2)
$HH = StringMid($filename, 13,2)
$MM = StringMid($filename, 15,2)
$SS = StringMid($filename, 17,2)

$formatted = StringFormat("%s/%s/%s %s:%s:%s",$YYYY,$MM,$DD,$HH,$MM,$SS)
ConsoleWrite($formatted)

If _DateDiff('h', $formatted, _NowCalc) > 5
    ;FileDelete($filename)
EndIf

Posted

ok,

you gave me a solution on how to know when 6 hours have passed. but what do I do when the time is 01:07:30 and the file names are:

010730.txt

010729.txt

.....

000030.txt

....

231000.txt

230000.txt

how do I tell it to del 5 hours before 01:00:00 at night.

I can solved this by doing "IF" statments, like :

if $H=01 then
$H1=20
$H2=21
$H3=22
$H4=23
$H5=24
filedelete ("c:\$H1*")
filedelete ("c:\$H2*")
filedelete ("c:\$H3*")
....
else if $H=00 then
$H1=19
$H2=21
...

I think you got my point now....


            
        

        

        
    

    
    

    

                    
                    
                        
                    
                    
                

                    

                    
                    






    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


martin
            
            
                Posted 
                
            
        
    
    
        


martin
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                MVPs
                
                    
                
            
            
                
                    
                        
                            
                                
                            
                                 7.1k
                            
                                
                            
                        
                        
                            
                                
                                    
                                        
                                        3
                                
                                    
                                
                            
                        
                    
                
            
            
                

    
    
        
~~\o/~~~/0\=¬''~~~
    
    

            
        
    
    
        



    
        
            
                
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
           
           Posted 
           
            
            
                
                    (edited)
                
                
            
        
    

    

    

    
        
        
            ok,

you gave me a solution on how to know when 6 hours have passed. but what do I do when the time is 01:07:30 and the file names are:

010730.txt
010729.txt
.....

000030.txt
....
231000.txt
230000.txt

how do I tell it to del 5 hours before 01:00:00 at night. 

I can solved this by doing "IF" statments, like :
if $H=01 then
$H1=20
$H2=21
$H3=22
$H4=23
$H5=24
filedelete ("c:\$H1*")
filedelete ("c:\$H2*")
filedelete ("c:\$H3*")
....
else if $H=00 then
$H1=19
$H2=21
...

I think you got my point now....

Couldn't you say

$H1 = $H0 - 5
If $H1 < 0 then $H1 += 24
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted

Couldn't you say

$H1 = $H0 - 5
If $H1 < 0 then $H1 += 24
Thanks martin. it is the hour here.... 01:08 AM... I need more coffee.....

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...