Sign in to follow this  
Followers 0
Necromorph

FileGetTime() by array, not working, why?

5 posts in this topic




#2 ·  Posted (edited)

Bad FOR statement

And filelisttoarray returns filenames, not full paths.

#include<File.au3>


$files = _FileListToArray(@MyDocumentsDir, "*.*", 1)
For $x = 1 to ubound($files) - 1
     $var = FileGetTime(@MyDocumentsDir & "\" & $files[$x], 0, 1)
MsgBox(0, '', $var)
Next

Edit: put the msgbox in the loop so you can see all the timestamps

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

redLabel,

any ideas why this doesn't work?

Several! :(

- 1. You need to specify a value for the end of your loop. That means the [0] element of $files - not the array itself.

- 2. _FileListToArray does not include the path in the return - so you have to add it yourself when you look for the file time.

If you do that you should find it works: :graduated:

#include<File.au3>

$files = _FileListToArray(@MyDocumentsDir, "*.*", 1)

For $x = 1 to $files[0]                                           ; <<<<<<<<<<<<<<<<<<<
     $var = FileGetTime(@MyDocumentsDir & "\" & $files[$x], 0, 1) ; <<<<<<<<<<<<<<<<<<<
     MsgBox(0, '', $var)
Next

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks, your statement answered my question

"And filelisttoarray returns filenames, not full paths."

this was just an example of what im doing not exactly what is in my script, that is why i didn't have the & "\" after the @MyDocumentsDir, forgot. thanks for you help.

Share this post


Link to post
Share on other sites

#include<File.au3>

$archivesLocalDir = @MyDocumentsDir & "\folder\Outlook Archives\"
$archivesNetworkDir = @HomeDrive & "\folder\Outlook Archives\"

If @HomeDrive <> "U:" or DriveStatus("U:") <> "Ready" Then
    Exit
Else
    _File_ModifiedCopy()
EndIf

Func _File_ModifiedCopy()
    $filesLocal = _FileListToArray($archivesLocalDir)

    For $x = 1 to UBound($filesLocal) - 1
        If Not FileExists($archivesNetworkDir & $filesLocal[$x]) Then
            FileCopy($archivesLocalDir & $filesLocal[$x], $archivesNetworkDir)
        Else
            If FileGetTime($archivesLocalDir & $filesLocal[$x], 0, 1) > FileGetTime($archivesNetworkDir & $filesLocal[$x], 0, 1) Then
                FileCopy($archivesLocalDir & $filesLocal[$x], $archivesNetworkDir, 1)
            EndIf
        EndIf
    Next
EndFunc

this is what i have, and it works to some extent, but i know its going to copy the entire dir contents if a file is changed or file is added, so i need help to only copy files that have changed. like i said this is working, but i think i have made it way to complicated. please help.

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