Jump to content

Help With Filegettime And Variables


Guest mwpdc
 Share

Recommended Posts

Guest mwpdc

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)

Link to comment
Share on other sites

  • Developers

$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)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

$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
Link to comment
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
 Share

  • Recently Browsing   0 members

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