timistar Posted February 5, 2009 Share Posted February 5, 2009 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 expandcollapse popup#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 More sharing options...
sandin Posted February 5, 2009 Share Posted February 5, 2009 expandcollapse popup#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. Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 5, 2009 Share Posted February 5, 2009 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 More sharing options...
timistar Posted February 11, 2009 Author Share Posted February 11, 2009 thx by the fast answer and sorrry by mi late answer, i keep the problem with your code or with mi code when i try to copy the new files of the usb in the folder dont copy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now