jerem488 Posted November 29, 2008 Share Posted November 29, 2008 Hello, I have a little problem I took a script but I would like to modify it using the "filegettime" and "filesettime" functions But I do not know why it is not working the program is : expandcollapse popupDim $source, $Destination, $date_modif, $date_creation, $date_acces Func DemandeSourceDestination() ; $source = c:\ati et $destination = c:\nouveau dossier $Source = FileSelectFolder("Veuillez sélectionner le répertoire source :",@HomeDrive&"\",2,@HomeDrive&"\") If @error = 1 Then Exit Else $Source &= "\" EndIf $Destination = FileSelectFolder("Veuillez sélectionner le répertoire destination :",@HomeDrive&"\",1,@HomeDrive&"\") If @error = 1 Then Exit Else If StringInStr($Destination,$Source,1) Then While StringInStr($Destination,$Source,1) MsgBox(0,"994","vous devez sélectionner un répertoire qui ne se situe pas dans votre répertoire source") $Destination = FileSelectFolder("Veuillez sélectionner le répertoire destination :",@HomeDrive&"\",1,@HomeDrive&"\") If @error = 1 Then Exit Else $Destination &= "\" EndIf WEnd Else $Destination &= "\" EndIf EndIf EndFunc DemandeSourceDestination() _CopyDirWithProgress($source,$Destination) Func _CopyDirWithProgress($sOriginalDir, $sDestDir) ;$sOriginalDir and $sDestDir are quite selfexplanatory... ;This func returns: ; -1 in case of critical error, bad original or destination dir ; 0 if everything went all right ; >0 is the number of file not copied and it makes a log file ; if in the log appear as error message '0 file copied' it is a bug of some windows' copy command that does not redirect output... If StringRight($sOriginalDir, 1) <> '\' Then $sOriginalDir = $sOriginalDir & '\' If StringRight($sDestDir, 1) <> '\' Then $sDestDir = $sDestDir & '\' If $sOriginalDir = $sDestDir Then Return -1 ProgressOn('Copie en cours...', 'Making list of files...' & @LF & @LF, '', -1, -1, 18) Local $aFileList = _FileSearch($sOriginalDir) If $aFileList[0] = 0 Then ProgressOff() SetError(1) Return -1 EndIf If FileExists($sDestDir) Then If Not StringInStr(FileGetAttrib($sDestDir), 'd') Then ProgressOff() SetError(2) Return -1 EndIf Else MsgBox(0,"4_","dircreate") DirCreate($sDestDir) If Not FileExists($sDestDir) Then ProgressOff() SetError(2) Return -1 EndIf EndIf Local $iDirSize, $iCopiedSize = 0, $fProgress = 0 Local $c, $FileName, $iOutPut = 0, $sLost = '', $sError Local $Sl = StringLen($sOriginalDir) _Quick_Sort($aFileList, 1, $aFileList[0]) $iDirSize = Int(DirGetSize($sOriginalDir) / 1024) ProgressSet(Int($fProgress * 100), $aFileList[$c], 'Coping file:') For $c = 1 To $aFileList[0] $FileName = StringTrimLeft($aFileList[$c], $Sl) ProgressSet(Int($fProgress * 100), $aFileList[$c] & ' -> '& $sDestDir & $FileName & @LF & 'Total KiB: ' & $iDirSize & @LF & 'Done KiB: ' & $iCopiedSize, 'Coping file: ' & Round($fProgress * 100, 2) & ' % ' & $c & '/' &$aFileList[0]) If StringInStr(FileGetAttrib($aFileList[$c]), 'd') Then DirCreate($sDestDir & $FileName) Else MsgBox(0,"5_2",$aFileList[$c]& @CRLF & $sOriginalDir & @CRLF &$sDestDir & @CRLF &$FileName) $date_modif = FileGetTime($sOriginalDir & $FileName,0);Récupère la date de modification If @error Then MsgBox(0,"1","Impossible de récupérer la date de modification de '" & $FileName & "'.") EndIf $date_creation = FileGetTime($sOriginalDir & $FileName,1);Récupère la date de création If @error Then MsgBox(0,"1","Impossible de récupérer la date de création de '" & $FileName & "'.") EndIf $date_acces = FileGetTime($sOriginalDir & $FileName,2);Récupère la date d'accès If @error Then MsgBox(0,"1","Impossible de récupérer la date d'accès de '" & $FileName & "'.") EndIf If Not FileCopy($aFileList[$c], $sDestDir & $FileName, 1) Then If Not FileCopy($aFileList[$c], $sDestDir & $FileName, 1) Then;Tries a second time If RunWait(@ComSpec & ' /c copy /y "' & $aFileList[$c] & '" "' & $sDestDir & $FileName & '">' & @TempDir & '\o.tmp', '', @SW_HIDE)=1 Then;and a third time, but this time it takes the error message $sError = FileReadLine(@TempDir & '\o.tmp',1) $iOutPut = $iOutPut + 1 $sLost = $sLost & $aFileList[$c] & ' ' & $sError & @CRLF EndIf FileDelete(@TempDir & '\o.tmp') EndIf EndIf MsgBox(0,"date",$date_modif&@CRLF& $date_creation&@CRLF& $date_acces) ModificationDate($sDestDir,$FileName,$date_modif,$date_creation,$date_acces) FileSetAttrib($sDestDir & $FileName, "+A-RSH");<- Comment this line if you do not want attribs reset. $iCopiedSize = $iCopiedSize + Int(FileGetSize($aFileList[$c]) / 1024) $fProgress = $iCopiedSize / $iDirSize EndIf Next ProgressOff() If $sLost <> '' Then;tries to write the log somewhere. If FileWrite($sDestDir & 'notcopied.txt',$sLost) = 0 Then If FileWrite($sOriginalDir & 'notcopied.txt',$sLost) = 0 Then FileWrite(@WorkingDir & '\notcopied.txt',$sLost) EndIf EndIf EndIf Return $iOutPut EndFunc ;==>_CopyDirWithProgress Func _FileSearch($sIstr, $bSF = 1) ; $bSF = 1 means looking in subfolders ; $sSF = 0 means looking only in the current folder. ; An array is returned with the full path of all files found. The pos [0] keeps the number of elements. Local $sCriteria, $sBuffer, $iH, $iH2, $sCS, $sCF, $sCF2, $sCP, $sFP, $sOutPut = '', $aNull[1] $sCP = StringLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCP = '' Then $sCP = @WorkingDir & '\' $sCriteria = StringTrimLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCriteria = '' Then $sCriteria = '*.*' ;To begin we seek in the starting path. $sCS = FileFindFirstFile($sCP & $sCriteria) If $sCS <> - 1 Then Do $sCF = FileFindNextFile($sCS) If @error Then FileClose($sCS) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop $sOutPut = $sOutPut & $sCP & $sCF & @LF Until 0 EndIf ;And after, if needed, in the rest of the folders. If $bSF = 1 Then $sBuffer = @CR & $sCP & '*' & @LF;The buffer is set for keeping the given path plus a *. Do $sCS = StringTrimLeft(StringLeft($sBuffer, StringInStr($sBuffer, @LF, 0, 1) - 1), 1);current search. $sCP = StringLeft($sCS, StringInStr($sCS, '\', 0, -1));Current search path. $iH = FileFindFirstFile($sCS) If $iH <> - 1 Then Do $sCF = FileFindNextFile($iH) If @error Then FileClose($iH) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop If StringInStr(FileGetAttrib($sCP & $sCF), 'd') Then $sBuffer = @CR & $sCP & $sCF & '\*' & @LF & $sBuffer;Every folder found is added in the begin of buffer $sFP = $sCP & $sCF & '\'; for future searches $iH2 = FileFindFirstFile($sFP & $sCriteria); and checked with the criteria. If $iH2 <> - 1 Then Do $sCF2 = FileFindNextFile($iH2) If @error Then FileClose($iH2) ExitLoop EndIf If $sCF2 = '.' Or $sCF2 = '..' Then ContinueLoop $sOutPut = $sOutPut & $sFP & $sCF2 & @LF;Found items are put in the Output. Until 0 EndIf EndIf Until 0 EndIf $sBuffer = StringReplace($sBuffer, @CR & $sCS & @LF, '') Until $sBuffer = '' EndIf If $sOutPut = '' Then $aNull[0] = 0 Return $aNull Else Return StringSplit(StringTrimRight($sOutPut, 1), @LF) EndIf EndFunc ;==>_FileSearch Func _Quick_Sort(ByRef $SortArray, $First, $Last);Larry's code Dim $Low, $High Dim $Temp, $List_Separator $Low = $First $High = $Last $List_Separator = StringLen($SortArray[ ($First + $Last) / 2]) Do While (StringLen($SortArray[$Low]) < $List_Separator) $Low = $Low + 1 WEnd While (StringLen($SortArray[$High]) > $List_Separator) $High = $High - 1 WEnd If ($Low <= $High) Then $Temp = $SortArray[$Low] $SortArray[$Low] = $SortArray[$High] $SortArray[$High] = $Temp $Low = $Low + 1 $High = $High - 1 EndIf Until $Low > $High If ($First < $High) Then _Quick_Sort($SortArray, $First, $High) If ($Low < $Last) Then _Quick_Sort($SortArray, $Low, $Last) EndFunc ;==>_Quick_Sort Func RecuperationDate($Source,$sCF) Local $date_modif, $date_creation, $date_acces ;MsgBox(0,"9",$Source & @CRLF & $Destination & @CRLF & $sCF & @CRLF & "9") ;MsgBox(0,"6",$sCP & $sCF & @CRLF & "8") $date_modif = FileGetTime($Source & $sCF,0);Récupère la date de modification If @error Then MsgBox(0,"1","Impossible de récupérer la date de modification de '" & $sCF & "'.") EndIf $date_creation = FileGetTime($Source & $sCF,1);Récupère la date de création If @error Then MsgBox(0,"1","Impossible de récupérer la date de création de '" & $sCF & "'.") EndIf $date_acces = FileGetTime($Source&$sCF,2);Récupère la date d'accès If @error Then MsgBox(0,"1","Impossible de récupérer la date d'accès de '" & $sCF & "'.") EndIf MsgBox(0,"date-2",$date_modif&@CRLF& $date_creation&@CRLF& $date_acces) EndFunc Func ModificationDate($Destination,$sCF,$date_modif,$date_creation,$date_acces) ;Local $date_modif, $date_creation, $date_acces FileSetTime($Destination & $sCF,$date_modif[0]&$date_modif[1]&$date_modif[2]&$date_modif[3]&$date_modif[4]&$date_modif[5],0) If @error Then MsgBox(0,"","error 0") EndIf FileSetTime($Destination & $sCF,$date_creation[0]&$date_creation[1]&$date_creation[2]&$date_creation[3]&$date_creation[4]&$date_creation[5],1) If @error Then MsgBox(0,"","error 1") EndIf FileSetTime($Destination & $sCF,$date_acces[0]&$date_acces[1]&$date_acces[2]&$date_acces[3]&$date_acces[4]&$date_acces[5],2) ;FileSetTime($Destination&$sCF,$date_modif,0) If @error Then MsgBox(0,"","error 2") EndIf EndFuncoÝ÷ ٩ݶ¡×°'!v¬mÂäÈ^殶sbf÷"b33c¶2ÒFòb33c¶fÆTÆ7E³Ð¢b33c´fÆTæÖRÒ7G&æuG&ÔÆVgBb33c¶fÆTÆ7E²b33c¶5ÒÂb33cµ6¢&öw&W756WBçBb33c¶e&öw&W72¢Âb33c¶fÆTÆ7E²b33c¶5Òfײb33²ÒfwC²b33²fײb33c·4FW7DF"fײb33c´fÆTæÖRfײÄbfײb33µF÷F¶#¢b33²fײb33c¶F%6¦RfײÄbfײb33´FöæR¶#¢b33²fײb33c¶6÷VE6¦RÂb33´6÷ærfÆS¢b33²fײ&÷VæBb33c¶e&öw&W72¢Â"fײb33²Rb33²fײb33c¶2fײb33²òb33²fײb33c¶fÆTÆ7E³Ò¢¢b7G&ætå7G"fÆTvWDGG&"b33c¶fÆTÆ7E²b33c¶5ÒÂb33¶Bb33²FVà¢F$7&VFRb33c·4FW7DF"fײb33c´fÆTæÖR VÇ6P ×6t&÷ÂgV÷C³Uó"gV÷C²Âb33c¶fÆTÆ7E²b33c¶5Òfײ5$Äbfײb33c·4÷&væÄF"fײ5$Äbfײb33c·4FW7DF"fײ5$Äbfײb33c´fÆTæÖR b33c¶FFUöÖöFbÒfÆTvWEFÖRb33c·4÷&væÄF"fײb33c´fÆTæÖRõ.7W&RÆFFRFRÖöFf6Föà bW'&÷"FVà ×6t&÷ÂgV÷C³gV÷C²ÂgV÷C´×÷76&ÆRFR.7W&W"ÆFFRFRÖöFf6FöâFRb33²gV÷C²fײb33c´fÆTæÖRfײgV÷C²b33²âgV÷C² VæD` b33c¶FFUö7&VFöâÒfÆTvWEFÖRb33c·4÷&væÄF"fײb33c´fÆTæÖRõ.7W&RÆFFRFR7.Föà bW'&÷"FVà ×6t&÷ÂgV÷C³gV÷C²ÂgV÷C´×÷76&ÆRFR.7W&W"ÆFFRFR7.FöâFRb33²gV÷C²fײb33c´fÆTæÖRfײgV÷C²b33²âgV÷C² VæD` b33c¶FFUö66W2ÒfÆTvWEFÖRb33c·4÷&væÄF"fײb33c´fÆTæÖRÃ"µ.7W&RÆFFRBb33¶6>0 bW'&÷"FVà ×6t&÷ÂgV÷C³gV÷C²ÂgV÷C´×÷76&ÆRFR.7W&W"ÆFFRBb33¶6>2FRb33²gV÷C²fײb33c´fÆTæÖRfײgV÷C²b33²âgV÷C² VæD` ¢bæ÷BfÆT6÷b33c¶fÆTÆ7E²b33c¶5ÒÂb33c·4FW7DF"fײb33c´fÆTæÖRÂFVà¢bæ÷BfÆT6÷b33c¶fÆTÆ7E²b33c¶5ÒÂb33c·4FW7DF"fײb33c´fÆTæÖRÂFVãµG&W26V6öæBFÖP¢b'VåvB6öÕ7V2fײb33²ö26÷÷gV÷C²b33²fײb33c¶fÆTÆ7E²b33c¶5Òfײb33²gV÷C²gV÷C²b33²fײb33c·4FW7DF"fײb33c´fÆTæÖRfײb33²gV÷C²fwC²b33²fײFV×F"fײb33²b3#¶òçF×b33²Âb33²b33²Â5uôDRÓFVã¶æBF&BFÖRÂ'WBF2FÖRBF¶W2FRW'&÷"ÖW76vP¢b33c·4W'&÷"ÒfÆU&VDÆæRFV×F"fײb33²b3#¶òçF×b33²Ã¢b33c¶÷WEWBÒb33c¶÷WEWB²¢b33c·4Æ÷7BÒb33c·4Æ÷7Bfײb33c¶fÆTÆ7E²b33c¶5Òfײb33²b33²fײb33c·4W'&÷"fײ5$Ä`¢VæD`¢fÆTFVÆWFRFV×F"fײb33²b3#¶òçF×b33² VæD` VæD` fÆU6WEFÖRb33c·4FW7DF"fײb33c´fÆTæÖRÂb33c¶FFUöÖöFe³Òfײb33c¶FFUöÖöFe³Òfײb33c¶FFUöÖöFe³%Òfײb33c¶FFUöÖöFe³5Òfײb33c¶FFUöÖöFe³EÒfײb33c¶FFUöÖöFe³UÒà bW'&÷"FVà ×6t&÷ÂgV÷C²gV÷C²ÂgV÷C¶W'&÷"gV÷C² VæD` fÆU6WEFÖRb33c²b33c·4FW7DF"fײb33c´fÆTæÖRÂb33c¶FFUö7&VFöå³Òfײb33c¶FFUö7&VFöå³Òfײb33c¶FFUö7&VFöå³%Òfײb33c¶FFUö7&VFöå³5Òfײb33c¶FFUö7&VFöå³EÒfײb33c¶FFUö7&VFöå³UÒà bW'&÷"FVà ×6t&÷ÂgV÷C²gV÷C²ÂgV÷C¶W'&÷"gV÷C² VæD` fÆU6WEFÖRb33c·4FW7DF"fײb33c´fÆTæÖRÂb33c¶FFUö66W5³Òfײb33c¶FFUö66W5³Òfײb33c¶FFUö66W5³%Òfײb33c¶FFUö66W5³5Òfײb33c¶FFUö66W5³EÒfײb33c¶FFUö66W5³UÒÃ" ´fÆU6WEFÖRb33c´FW7FæFöâfײb33c·44bÂb33c¶FFUöÖöFbà bW'&÷"FVà ×6t&÷ÂgV÷C²gV÷C²ÂgV÷C¶W'&÷""gV÷C² VæD` ¢fÆU6WDGG&"b33c·4FW7DF"fײb33c´fÆTæÖRÂgV÷C²´Õ%4gV÷C²²fÇC²Ò6öÖÖVçBF2ÆæRb÷RFòæ÷BvçBGG&'2&W6WBࢢb33c¶6÷VE6¦RÒb33c¶6÷VE6¦R²çBfÆTvWE6¦Rb33c¶fÆTÆ7E²b33c¶5Òò#B¢b33c¶e&öw&W72Òb33c¶6÷VE6¦Ròb33c¶F%6¦P¢VæD`¢æW@ thank you Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
BrettF Posted November 29, 2008 Share Posted November 29, 2008 Does the file exist? What is are the FileTime () functions returning? Check them and see how you go Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
jerem488 Posted November 29, 2008 Author Share Posted November 29, 2008 yes of course the file exist ! I put a msgbox outside to launch the filegettime function. And th file exist ! ! the copy of the file work but the filegettime and fileset time doesn't work Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
BrettF Posted November 29, 2008 Share Posted November 29, 2008 You use a big line here: FileSetTime($sDestDir & $FileName,$date_modif[0]&$date_modif[1]&$date_modif[2]&$date_modif[3]&$date_modif[4]&$date_modif[5],0) Whats the value of $sDestDir & $FileName,$date_modif[0]&$date_modif[1]&$date_modif[2]&$date_modif[3]&$date_modif[4]&$date_modif[5]? That could cause problems... What exactly isn't working for you? Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
jerem488 Posted November 29, 2008 Author Share Posted November 29, 2008 (edited) Hello, SO, it's good. This code work : expandcollapse popupDim $source, $Destination, $date_modif, $date_creation, $date_acces Func DemandeSourceDestination() ; $source = c:\ati et $destination = c:\nouveau dossier $Source = FileSelectFolder("Veuillez sélectionner le répertoire source :",@HomeDrive&"\",2,@HomeDrive&"\") If @error = 1 Then Exit Else $Source &= "\" EndIf $Destination = FileSelectFolder("Veuillez sélectionner le répertoire destination :",@HomeDrive&"\",1,@HomeDrive&"\") If @error = 1 Then Exit Else If StringInStr($Destination,$Source,1) Then While StringInStr($Destination,$Source,1) MsgBox(0,"994","vous devez sélectionner un répertoire qui ne se situe pas dans votre répertoire source") $Destination = FileSelectFolder("Veuillez sélectionner le répertoire destination :",@HomeDrive&"\",1,@HomeDrive&"\") If @error = 1 Then Exit Else $Destination &= "\" EndIf WEnd Else $Destination &= "\" EndIf EndIf EndFunc DemandeSourceDestination() _CopyDirWithProgress($source,$Destination) Func _CopyDirWithProgress($sOriginalDir, $sDestDir) ;$sOriginalDir and $sDestDir are quite selfexplanatory... ;This func returns: ; -1 in case of critical error, bad original or destination dir ; 0 if everything went all right ; >0 is the number of file not copied and it makes a log file ; if in the log appear as error message '0 file copied' it is a bug of some windows' copy command that does not redirect output... If StringRight($sOriginalDir, 1) <> '\' Then $sOriginalDir = $sOriginalDir & '\' If StringRight($sDestDir, 1) <> '\' Then $sDestDir = $sDestDir & '\' If $sOriginalDir = $sDestDir Then Return -1 ProgressOn('Copie en cours...', 'Making list of files...' & @LF & @LF, '', -1, -1, 18) Local $aFileList = _FileSearch($sOriginalDir) If $aFileList[0] = 0 Then ProgressOff() SetError(1) Return -1 EndIf If FileExists($sDestDir) Then If Not StringInStr(FileGetAttrib($sDestDir), 'd') Then ProgressOff() SetError(2) Return -1 EndIf Else MsgBox(0,"4_","dircreate") DirCreate($sDestDir) If Not FileExists($sDestDir) Then ProgressOff() SetError(2) Return -1 EndIf EndIf Local $iDirSize, $iCopiedSize = 0, $fProgress = 0 Local $c, $FileName, $iOutPut = 0, $sLost = '', $sError Local $Sl = StringLen($sOriginalDir) _Quick_Sort($aFileList, 1, $aFileList[0]) $iDirSize = Int(DirGetSize($sOriginalDir) / 1024) ProgressSet(Int($fProgress * 100), $aFileList[$c], 'Coping file:') For $c = 1 To $aFileList[0] $FileName = StringTrimLeft($aFileList[$c], $Sl) ProgressSet(Int($fProgress * 100), $aFileList[$c] & ' -> '& $sDestDir & $FileName & @LF & 'Total KiB: ' & $iDirSize & @LF & 'Done KiB: ' & $iCopiedSize, 'Coping file: ' & Round($fProgress * 100, 2) & ' % ' & $c & '/' &$aFileList[0]) If StringInStr(FileGetAttrib($aFileList[$c]), 'd') Then $date_modif = FileGetTime($sOriginalDir & $FileName,0);Récupère la date de modification If @error Then MsgBox(0,"1","Impossible de récupérer la date de modification de '" & $FileName & "'.") EndIf $date_creation = FileGetTime($sOriginalDir & $FileName,1);Récupère la date de création If @error Then MsgBox(0,"1","Impossible de récupérer la date de création de '" & $FileName & "'.") EndIf $date_acces = FileGetTime($sOriginalDir & $FileName,2);Récupère la date d'accès If @error Then MsgBox(0,"1","Impossible de récupérer la date d'accès de '" & $FileName & "'.") EndIf ;MsgBox(0,"dir",$date_modif[0]&$date_modif[1]&$date_modif[2]&$date_modif[3]&$date_modif[4]&$date_modif[5]&@CRLF&$date_creation[0]&$date_creation[1]&$date_creation[2]&$date_creation[3]&$date_creation[4]&$date_creation[5] & _ ;@CRLF & $date_acces[0]&$date_acces[1]&$date_acces[2]&$date_acces[3]&$date_acces[4]&$date_acces[5]) DirCreate($sDestDir & $FileName) FileSetTime($sDestDir & $FileName,$date_modif[0]&$date_modif[1]&$date_modif[2]&$date_modif[3]&$date_modif[4]&$date_modif[5],0) If @error Then MsgBox(0,"","error 0") EndIf FileSetTime($sDestDir & $FileName,$date_creation[0]&$date_creation[1]&$date_creation[2]&$date_creation[3]&$date_creation[4]&$date_creation[5],1) If @error Then MsgBox(0,"","error 1") EndIf FileSetTime($sDestDir & $FileName,$date_acces[0]&$date_acces[1]&$date_acces[2]&$date_acces[3]&$date_acces[4]&$date_acces[5],2) ;FileSetTime($Destination&$sCF,$date_modif,0) If @error Then MsgBox(0,"","error 2") EndIf Else ;MsgBox(0,"5_2",$aFileList[$c]& @CRLF & $sOriginalDir & @CRLF &$sDestDir & @CRLF &$FileName) $date_modif = FileGetTime($sOriginalDir & $FileName,0);Récupère la date de modification If @error Then MsgBox(0,"1","Impossible de récupérer la date de modification de '" & $FileName & "'.") EndIf $date_creation = FileGetTime($sOriginalDir & $FileName,1);Récupère la date de création If @error Then MsgBox(0,"1","Impossible de récupérer la date de création de '" & $FileName & "'.") EndIf $date_acces = FileGetTime($sOriginalDir & $FileName,2);Récupère la date d'accès If @error Then MsgBox(0,"1","Impossible de récupérer la date d'accès de '" & $FileName & "'.") EndIf ;MsgBox(0,"file",$date_modif[0]&$date_modif[1]&$date_modif[2]&$date_modif[3]&$date_modif[4]&$date_modif[5]&@CRLF&$date_creation[0]&$date_creation[1]&$date_creation[2]&$date_creation[3]&$date_creation[4]&$date_creation[5] & _ ;@CRLF & $date_acces[0]&$date_acces[1]&$date_acces[2]&$date_acces[3]&$date_acces[4]&$date_acces[5]) If Not FileCopy($aFileList[$c], $sDestDir & $FileName, 1) Then If Not FileCopy($aFileList[$c], $sDestDir & $FileName, 1) Then;Tries a second time If RunWait(@ComSpec & ' /c copy /y "' & $aFileList[$c] & '" "' & $sDestDir & $FileName & '">' & @TempDir & '\o.tmp', '', @SW_HIDE)=1 Then;and a third time, but this time it takes the error message $sError = FileReadLine(@TempDir & '\o.tmp',1) $iOutPut = $iOutPut + 1 $sLost = $sLost & $aFileList[$c] & ' ' & $sError & @CRLF EndIf FileDelete(@TempDir & '\o.tmp') EndIf EndIf ;MsgBox(0,"date",$date_modif&@CRLF& $date_creation&@CRLF& $date_acces) FileSetTime($sDestDir & $FileName,$date_modif[0]&$date_modif[1]&$date_modif[2]&$date_modif[3]&$date_modif[4]&$date_modif[5],0) If @error Then MsgBox(0,"","error 0") EndIf FileSetTime($sDestDir & $FileName,$date_creation[0]&$date_creation[1]&$date_creation[2]&$date_creation[3]&$date_creation[4]&$date_creation[5],1) If @error Then MsgBox(0,"","error 1") EndIf FileSetTime($sDestDir & $FileName,$date_acces[0]&$date_acces[1]&$date_acces[2]&$date_acces[3]&$date_acces[4]&$date_acces[5],2) ;FileSetTime($Destination&$sCF,$date_modif,0) If @error Then MsgBox(0,"","error 2") EndIf ModificationDate($sDestDir,$FileName,$date_modif,$date_creation,$date_acces) FileSetAttrib($sDestDir & $FileName, "+A-RSH");<- Comment this line if you do not want attribs reset. $iCopiedSize = $iCopiedSize + Int(FileGetSize($aFileList[$c]) / 1024) $fProgress = $iCopiedSize / $iDirSize EndIf Next ProgressOff() If $sLost <> '' Then;tries to write the log somewhere. If FileWrite($sDestDir & 'notcopied.txt',$sLost) = 0 Then If FileWrite($sOriginalDir & 'notcopied.txt',$sLost) = 0 Then FileWrite(@WorkingDir & '\notcopied.txt',$sLost) EndIf EndIf EndIf Return $iOutPut EndFunc ;==>_CopyDirWithProgress Func _FileSearch($sIstr, $bSF = 1) ; $bSF = 1 means looking in subfolders ; $sSF = 0 means looking only in the current folder. ; An array is returned with the full path of all files found. The pos [0] keeps the number of elements. Local $sCriteria, $sBuffer, $iH, $iH2, $sCS, $sCF, $sCF2, $sCP, $sFP, $sOutPut = '', $aNull[1] $sCP = StringLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCP = '' Then $sCP = @WorkingDir & '\' $sCriteria = StringTrimLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCriteria = '' Then $sCriteria = '*.*' ;To begin we seek in the starting path. $sCS = FileFindFirstFile($sCP & $sCriteria) If $sCS <> - 1 Then Do $sCF = FileFindNextFile($sCS) If @error Then FileClose($sCS) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop $sOutPut = $sOutPut & $sCP & $sCF & @LF Until 0 EndIf ;And after, if needed, in the rest of the folders. If $bSF = 1 Then $sBuffer = @CR & $sCP & '*' & @LF;The buffer is set for keeping the given path plus a *. Do $sCS = StringTrimLeft(StringLeft($sBuffer, StringInStr($sBuffer, @LF, 0, 1) - 1), 1);current search. $sCP = StringLeft($sCS, StringInStr($sCS, '\', 0, -1));Current search path. $iH = FileFindFirstFile($sCS) If $iH <> - 1 Then Do $sCF = FileFindNextFile($iH) If @error Then FileClose($iH) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop If StringInStr(FileGetAttrib($sCP & $sCF), 'd') Then $sBuffer = @CR & $sCP & $sCF & '\*' & @LF & $sBuffer;Every folder found is added in the begin of buffer $sFP = $sCP & $sCF & '\'; for future searches $iH2 = FileFindFirstFile($sFP & $sCriteria); and checked with the criteria. If $iH2 <> - 1 Then Do $sCF2 = FileFindNextFile($iH2) If @error Then FileClose($iH2) ExitLoop EndIf If $sCF2 = '.' Or $sCF2 = '..' Then ContinueLoop $sOutPut = $sOutPut & $sFP & $sCF2 & @LF;Found items are put in the Output. Until 0 EndIf EndIf Until 0 EndIf $sBuffer = StringReplace($sBuffer, @CR & $sCS & @LF, '') Until $sBuffer = '' EndIf If $sOutPut = '' Then $aNull[0] = 0 Return $aNull Else Return StringSplit(StringTrimRight($sOutPut, 1), @LF) EndIf EndFunc ;==>_FileSearch Func _Quick_Sort(ByRef $SortArray, $First, $Last);Larry's code Dim $Low, $High Dim $Temp, $List_Separator $Low = $First $High = $Last $List_Separator = StringLen($SortArray[ ($First + $Last) / 2]) Do While (StringLen($SortArray[$Low]) < $List_Separator) $Low = $Low + 1 WEnd While (StringLen($SortArray[$High]) > $List_Separator) $High = $High - 1 WEnd If ($Low <= $High) Then $Temp = $SortArray[$Low] $SortArray[$Low] = $SortArray[$High] $SortArray[$High] = $Temp $Low = $Low + 1 $High = $High - 1 EndIf Until $Low > $High If ($First < $High) Then _Quick_Sort($SortArray, $First, $High) If ($Low < $Last) Then _Quick_Sort($SortArray, $Low, $Last) EndFunc ;==>_Quick_Sort Func RecuperationDate($Source,$sCF) Local $date_modif, $date_creation, $date_acces ;MsgBox(0,"9",$Source & @CRLF & $Destination & @CRLF & $sCF & @CRLF & "9") ;MsgBox(0,"6",$sCP & $sCF & @CRLF & "8") $date_modif = FileGetTime($Source & $sCF,0);Récupère la date de modification If @error Then MsgBox(0,"1","Impossible de récupérer la date de modification de '" & $sCF & "'.") EndIf $date_creation = FileGetTime($Source & $sCF,1);Récupère la date de création If @error Then MsgBox(0,"1","Impossible de récupérer la date de création de '" & $sCF & "'.") EndIf $date_acces = FileGetTime($Source&$sCF,2);Récupère la date d'accès If @error Then MsgBox(0,"1","Impossible de récupérer la date d'accès de '" & $sCF & "'.") EndIf MsgBox(0,"date-2",$date_modif&@CRLF& $date_creation&@CRLF& $date_acces) EndFunc Func ModificationDate($Destination,$sCF,$date_modif,$date_creation,$date_acces) ;Local $date_modif, $date_creation, $date_acces FileSetTime($Destination & $sCF,$date_modif[0]&$date_modif[1]&$date_modif[2]&$date_modif[3]&$date_modif[4]&$date_modif[5],0) If @error Then MsgBox(0,"","error 0") EndIf FileSetTime($Destination & $sCF,$date_creation[0]&$date_creation[1]&$date_creation[2]&$date_creation[3]&$date_creation[4]&$date_creation[5],1) If @error Then MsgBox(0,"","error 1") EndIf FileSetTime($Destination & $sCF,$date_acces[0]&$date_acces[1]&$date_acces[2]&$date_acces[3]&$date_acces[4]&$date_acces[5],2) ;FileSetTime($Destination&$sCF,$date_modif,0) If @error Then MsgBox(0,"","error 2") EndIf EndFunc But the problem is for each subfolder. For example for the folder called "folder1". This folder has a subfolder called "folder2". I want copy the "folder1" and all files and folders in this folder. First I get the dates of the folder1, then I copy this folder (in fact I use the filecreate function) in the destination directory. Then, I use the fileSetTime function to Set the timestamp of the folder1 gatting outside. After, I get the dates of the folder2 (in the folder1). But after, when I create the folder2 in the destiantion directory, the dates (modification and access) of the folder1 changes ! ! ! And In fact, I must create as many variables as there are subfolders in a folder. But I don't know how to do this.... thank you Edited December 1, 2008 by jerem488 Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
jerem488 Posted December 1, 2008 Author Share Posted December 1, 2008 (edited) I think use the _arraycreate and _arraydelete functions ??? In fact I must know how many subfolders there are in a folder.... Edited December 1, 2008 by jerem488 Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
FaT3oYCG Posted December 1, 2008 Share Posted December 1, 2008 DirCopy() DirMove() FileCopy() FileMove() check them out in the help file. Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right. Link to comment Share on other sites More sharing options...
jerem488 Posted December 1, 2008 Author Share Posted December 1, 2008 Yes, I know... And what ?? And I can't use dircopy() because this function copies all sub-directories. and I must get the time and date information of each folder. Qui ose gagneWho Dares Win[left]CyberExploit[/left] 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