Somerset Posted September 18, 2005 Posted September 18, 2005 (edited) this is a script you put in the folder you want backed up. it reads through it recursive like through the folders. then writes a script out with a progress bar set ever so often according to the numbers of files found. just compile the resulting script and the folder is backed up, this script whatever it's name and the resulting script isn't backed up into the exe. expandcollapse popupFileWrite(@MON & "-" & @MDAY & "-" & @YEAR & ".txt", @ScriptDir & @CRLF) $Stack = @ScriptDir & ">" $FileList = @ScriptDir & ">" While $Stack <> "" $root = StringLeft($Stack, StringInStr($Stack, ">") - 1) & "\" $Stack = StringTrimLeft($Stack, StringInStr($Stack, ">")) $h = FileFindFirstFile($root & "*.*") If $h > - 1 Then $FileFound = FileFindNextFile($h) While Not @Error And $FileFound <> "" If $FileFound <> "." And $FileFound <> ".." And _ StringInStr(FileGetAttrib($root & $FileFound), "D") Then $Stack = $Stack & $root & $FileFound & ">" $FileList = $FileList & $root & $FileFound & @CRLF EndIf $FileFound = FileFindNextFile($h) WEnd FileClose($h) EndIf WEnd $cleanup = StringReplace($FileList, ">", @CRLF) $items = StringSplit($cleanup, @CRLF) For $x = 1 To $items[0] If $items[$x] <> "" Then $search = FileFindFirstFile($items[$x] & "\*.*") 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 If $file <> "." And $file <> ".." And $file <> @ScriptName And $file <> @MON & "-" & @MDAY & "-" & @YEAR & ".txt"Then $allfilesandfolders = "" $allfilesandfolders = $items[$x] & "\" & $file & @CRLF FileWrite(@MON & "-" & @MDAY & "-" & @YEAR & ".txt", $allfilesandfolders) Else EndIf WEnd FileClose($search) Else EndIf Next #include <file.au3> Dim $aRecords If Not _FileReadToArray(@MON & "-" & @MDAY & "-" & @YEAR & ".txt", $aRecords) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 To $aRecords[0] $info = FileGetAttrib($aRecords[$x]) $looky = StringInStr($info, "D") If $looky <> 0 Then FileWrite("backup.au3", Chr(68) & Chr(105) & Chr(114) & Chr(67) & Chr(114) & Chr(101) & Chr(97) & Chr(116) & Chr(101) & Chr(40) & Chr(34) & $aRecords[$x] & Chr(34) & Chr(32) & Chr(41) & @CRLF) Else If $aRecords[$x] = "" Then Else FileWrite("backup.au3", Chr(70) & Chr(105) & Chr(108) & Chr(101) & Chr(73) & Chr(110) & Chr(115) & Chr(116) & Chr(97) & Chr(108) & Chr(108) & Chr(40) & Chr(34) & $aRecords[$x] & Chr(34) & Chr(44) & Chr(34) & $aRecords[$x] & Chr(34) & Chr(41) & @CRLF) EndIf EndIf Next $item = FileOpen("backup.au3", 0) #include <file.au3> $CountLines = _FileCountLines("backup.au3") $CountLines = $CountLines / 100 If $CountLines < 1 Then $CountLines = $CountLines + 1 Else EndIf $wholenumber = $CountLines While 1 $counter = StringIsDigit($wholenumber) If $counter = 0 Then $doublechecking = StringTrimRight($wholenumber, 1) $wholenumber = $doublechecking Else ExitLoop EndIf WEnd If $item = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $zed = -1 $beta = 0 FileWrite(@MON & "-" & @MDAY & "-" & @YEAR & ".au3", Chr(80) & Chr(114) & Chr(111) & Chr(103) & Chr(114) & Chr(101) & Chr(115) & Chr(115) & Chr(79) & Chr(110) & Chr(40) & Chr(34) & Chr(73) & Chr(110) & Chr(115) & Chr(116) & Chr(97) & Chr(108) & Chr(108) & Chr(105) & Chr(110) & Chr(103) & Chr(34) & Chr(44) & Chr(32) & Chr(34) & Chr(73) & Chr(110) & Chr(115) & Chr(116) & Chr(97) & Chr(108) & Chr(108) & Chr(105) & Chr(110) & Chr(103) & Chr(34) & Chr(44) & Chr(32) & Chr(34) & Chr(48) & Chr(32) & Chr(112) & Chr(101) & Chr(114) & Chr(99) & Chr(101) & Chr(110) & Chr(116) & Chr(34) & Chr(41) & @CRLF) While 1 $beta = $beta + 1 For $zed = 1 To $wholenumber $tot = FileReadLine($item) If @error = -1 Then ExitLoop FileWrite(@MON & "-" & @MDAY & "-" & @YEAR & ".au3", $tot & @CRLF) Next If @error = -1 Then ExitLoop If $beta <> 101 And $beta < 101 Then FileWrite(@MON & "-" & @MDAY & "-" & @YEAR & ".au3", Chr(80) & Chr(114) & Chr(111) & Chr(103) & Chr(114) & Chr(101) & Chr(115) & Chr(115) & Chr(83) & Chr(101) & Chr(116) & Chr(40) & $beta & "," & $beta & Chr(38) & Chr(34) & Chr(32) & Chr(112) & Chr(101) & Chr(114) & Chr(99) & Chr(101) & Chr(110) & Chr(116) & Chr(34) & Chr(41) & @CRLF) Else EndIf WEnd FileWrite(@MON & "-" & @MDAY & "-" & @YEAR & ".au3", Chr(80) & Chr(114) & Chr(111) & Chr(103) & Chr(114) & Chr(101) & Chr(115) & Chr(115) & Chr(83) & Chr(101) & Chr(116) & Chr(40) & "100,100 &' Done'" & ")" & "" & @CRLF) FileWrite(@MON & "-" & @MDAY & "-" & @YEAR & ".au3", Chr(80) & Chr(114) & Chr(111) & Chr(103) & Chr(114) & Chr(101) & Chr(115) & Chr(115) & Chr(79) & Chr(102) & Chr(102) & Chr(40) & Chr(41) & @CRLF) FileClose($item) FileDelete(@MON & "-" & @MDAY & "-" & @YEAR & ".txt") FileDelete("backup.au3") MsgBox(64, "Attention", "Now compile " & @MON & "-" & @MDAY & "-" & @YEAR & ".au3 to back up the desired folder...") Edited September 18, 2005 by beerman
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