Jump to content

Recommended Posts

Guest mwpdc
Posted

Need some help with FileGetTime and variables

  Quote

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

  • Developers
Posted

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

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
Guest mwpdc
Posted

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

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