Sign in to follow this  
Followers 0
Guest mwpdc

Help With Filegettime And Variables

4 posts in this topic

Need some help with FileGetTime and variables

$search = FileFindFirstFile("d:\pics\*.jpg") 

If $search = -1 Then

    MsgBox(0, "Error", "No files/directories matched the search pattern")

    Exit

EndIf

While 1

    $file = FileFindNextFile($search)

    If @error Then ExitLoop

    $t =  FileGetTime($file)

    $yyyymd = $t[0]& "/" & $t[1] & "/" & $t[2]

    MsgBox(0, $file , $yyyymd)

WEnd

FileClose($search)

$t comes back with a value of 1 (failure)

I need to scan the directory and do a check on every file for it's modified time; if it is older than 48 hours, then the file is to be deleted (that is not coded in yet).

Can anyone help? (thanks)

Share this post


Link to post
Share on other sites



$file contains only the filename ...not the total path..

this way it should work:

$dir="d:\pics\"
$search = FileFindFirstFile($dir & "*.jpg")  

If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $t =  FileGetTime($dir & $file)
    $yyyymd = $t[0] & "/" & $t[1] & "/" & $t[2]
    MsgBox(0, $file , $yyyymd)
WEnd

FileClose($search)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

$file is being set to just the filename without the path. if you use the full path for the FileGetTime function it should work (worked for me).

$t = FileGetTime( "d:\pics\" & $file )

EDIT:

I took too long to type. Sorry for the dupe.

Edited by etn

Share this post


Link to post
Share on other sites

Thanks for the quick turn around (you guys are awesome) :D

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0