Jump to content

array problem newbie


 Share

Recommended Posts

hi

somebody can tell waht is wrong with this, i can`t understand , i`m very very new with autoit and programing

thx

mi intention is

using the filegetime see the dif date between 1 file in the pc and the files into pendrive and copy only the files created after the create the date of the reference file

thx

#Include <File.au3>
#Include <Array.au3>
#Include <date.au3>

Dim $aDrives = _DriveGet()

$1Time = FileGetTime("C:\error.log");reference  file  only for the  FileGetTime
$Time1 = $1Time[2] & "/" & $1Time[1] & "/" & $1Time[0]

$drv = _DriveGet()

$FileList=_FileListToArray($drv)    
$usb = FileGetTime ($FileList)
$usbdrive= $usb[2] & "/" & $usb[1] & "/" & $usb[0]
If $time1 < $usb Then
    
       dircopy ("c:\westwood", "c:\lir", 1);  folder for test purpouses 
EndIf

#cs 

mi intention is  copy the  file contained into the pendrive  to  a folder  in  other loction ,  but  i can`t  if no copy  copy  all  files ,   i nned copy only the created afted  the reference  file  no all
but  have the  proble m of  "sub  scruipt  used with out  array  varable  o r   something  by the style "


#ce

;*****func  detectar usb por gna08

Func _DriveGet()
   Local $aDrive = DriveGetDrive("REMOVABLE")
   If @error Then Return False
   
   Local $iCount = 0, $aRetDrive[1], $i
   
   For $i = 1 To $aDrive[0]
      If ($aDrive[$i] = "a:") Or (DriveStatus($aDrive[$i]) <> "READY") Then ContinueLoop
      $aRetDrive[0] += 1
      ReDim $aRetDrive[$aRetDrive[0] + 1]
      $aRetDrive[$aRetDrive[0]] = StringUpper($aDrive[$i])
      Return StringUpper($aDrive[$i])
      $iCount += 1
   Next
   If $iCount <> "0" Then Return True
   Return $aRetDrive
EndFunc

many many thx

Link to comment
Share on other sites

#Include <File.au3>
#Include <Array.au3>
#Include <date.au3>
#Include <WinApi.au3>

$HDD_File = "C:\Error.Log"
$hFile = _WinAPI_CreateFile($HDD_File, 2)
if $hFile = 0 then _WinAPI_ShowError("Unable to open file")
$drv = _DriveGet()
$FileList=_FileListToArray($drv, "*", 1)

for $i = 1 to $FileList[0]
    Local $2nd_file = $drv & "\" & $FileList[$i]
    Local $compared_file = _WinAPI_CreateFile($2nd_file, 2, 2)
    if $compared_file = 0 then _WinAPI_ShowError("Unable to open file")
    Local $time1 = _Date_Time_GetFileTime($hFile)
    Local $time2 = _Date_Time_GetFileTime($compared_file)
    $pFiletime1 = DllStructGetPtr($time1[0])
    $pFiletime2 = DllStructGetPtr($time2[0])
    $comparison = _Date_Time_CompareFileTime($pFiletime1, $pFiletime2)
    Switch $comparison
        case -1
            MsgBox(0, "", "File: " & $HDD_file & " was made before file: " & $2nd_file)
            ;do something instead of msgbox display
        case 0
            MsgBox(0, "", "Files: " & $HDD_file & " and " & $2nd_file & " was made at the same time")
            ;do something instead of msgbox display
        case 1
            MsgBox(0, "", "File: " & $2nd_file & " was made before file: " & $HDD_file)
            ;do something instead of msgbox display
    EndSwitch
    _WinAPI_CloseHandle($compared_file)
Next

_WinAPI_CloseHandle($hFile)

Func _DriveGet()
    Local $aDrive = DriveGetDrive("REMOVABLE")
    Local $return_value
    For $i = 1 To $aDrive[0]
        If ($aDrive[$i] <> "a:") AND (DriveStatus($aDrive[$i]) = "READY") Then
            $return_value = $aDrive[$i]
            ExitLoop
        EndIf
   Next
   Return $return_value
EndFunc

though it works if only 1 USB drive is connected.

Link to comment
Share on other sites

hi

somebody can tell waht is wrong with this, i can`t understand , i`m very very new with autoit and programing

thx

mi intention is

using the filegetime see the dif date between 1 file in the pc and the files into pendrive and copy only the files created after the create the date of the reference file

thx

;...

$FileList=_FileListToArray($drv)    
$usb = FileGetTime ($FileList)

;...

many many thx

The _FileListToArray() function returns an array of file names (see the example script in the help file), not a single file name.

The function FileGetTime() requires a single file name to operate on, not an array for input (see the example in the help file).

You need a For/Next (see the example in the help file) loop to operate on each file returned in the $FileList array.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...