33 posts in this topic
Is it possible to post into the usenet with autoit ?
is there a way to post into the "Usenet" with autoit ?
I didn't found any resources about it online.
Nimps Folder Backup
"Nimps" is a regional slang word, which means easy or simple or basic and such.
I made a quick little script the other day to backup the visual studio project folder I was actively working on.
Thought I'd generalise it for use with the current active windows explorer folder.
When this script is running, and you hit "Ctrl and Shift and b", if a folder is open in windows explorer, it will copy the contents of it to your desired location ($GENERAL_BACKUP_FOLDER) including subfolders and its files and folders (so beware on deep directories)
If you have command line version of 7zip (7za.exe) you can choose to compress the folder rather than just copy it ($ZIP_FOLDER = True), or both I suppose.
Think that's all.
Reading the code should tell you anything else.
Oh, success or failure is indicated by a high or low frequency Beep().
#include <AutoItConstants.au3> #include <String.au3> HotKeySet("^+b", _Backup) ; ctrl and shift and b HotKeySet("!+b", _Exit) ; alt and shift and b Global Const $GENERAL_BACKUP_FOLDER = @ScriptDir & "Backup\" Global Const $ZIP_FOLDER = False Global Const $PATH_TO_7ZA = "D:\7za.exe" While 3 Sleep(300) WEnd ; High frequency beep if successful ; Low frequency beep if failed Func _Backup() Local $FOLDER_TO_BACKUP = "" Local $BACKUP_FOLDER = "" Local $CURRENT_BACKUP_FOLDER Local $WIN_TITLE = WinGetTitle("[Active]") Local $WIN_TEXT = WinGetText("[Active]") ; If text of window has no address, it is not a windows explorer If StringInStr($WIN_TEXT, "Address: ") Then Local $ACTIVE_EXPLORER_ADDRESS = _StringBetween($WIN_TEXT, "Address: ", @LF) If Not IsArray($ACTIVE_EXPLORER_ADDRESS) Then Beep(400, 150) Return @ScriptLineNumber EndIf $FOLDER_TO_BACKUP = $ACTIVE_EXPLORER_ADDRESS Else Return MsgBox(0, "Info", "The active window is not explorer") EndIf ; Check to see if root drive is backup source If StringRight($FOLDER_TO_BACKUP, 2) = ":\" Then $Answer = MsgBox(4, "Warning", "You are about to attempt to backup a whole disk" & @CRLF & "Are you sure?") If $Answer <> 6 Then Return EndIf ; Date and time to append to backup zip file or folder $APPEND = "_" & @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "_" & @MIN & "_" & @SEC Local $CURRENT_BACKUP_FOLDER = $GENERAL_BACKUP_FOLDER & $WIN_TITLE & $APPEND ; Zip to backup folder and return, 7za.exe required If $ZIP_FOLDER Then ; Buile command for 7za $command = $PATH_TO_7ZA & ' a ' & '"' & $GENERAL_BACKUP_FOLDER & $WIN_TITLE & $APPEND & '"' & '.zip ' & '"' & $FOLDER_TO_BACKUP & '"' $pid = Run($command, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While ProcessExists($pid) Sleep(10) WEnd $out = StdoutRead($pid) ; Indicate if successfull If StringInStr($out, "Everything is Ok") Then Beep(700, 200) Return EndIf Beep(400, 200) Return EndIf ; Copy folder and beep when complete, no 7zip needed. Local $RTN = DirCopy($FOLDER_TO_BACKUP, $CURRENT_BACKUP_FOLDER, 1) ? Beep(700, 500) : Beep(400, 500) EndFunc ;==>_Backup Func _Exit() Exit EndFunc ;==>_Exit
Making a backup of the entire Registry
I wanted to have a few lines that copy the whole registry into a file. I know that there is RegRead, but I don't want to type every single key into my code...
Any way of doing this easily? Filetype doesn't matter, as long as it isn't encrypted. A batch or exe would be okay, if it's in the same location on every PC. Doing this without admin permissions would be awesome too
Do a backup of a folders list
WARNING: I never tried this on a root directory, I should probably write a fix for that case. EX: There is no C:\..\
I don't know how many of these there are on this forum and I know Tidy is real nice for making backups.
I have a few dislikes relying on the Tidy backup:
1 I'm not crazy about the backup folder it creates in project folder.
2. If no Tidy edits are performed script is not backed up on Tidy. I can't rely on that when I request a backup.
3. If I want to backup a select group of files without backing up the entire project folder, it is somewhat tedious to select each file and Tidy.
Now this is just a very simple script that I felt I could use to simplify backing up my project.
I'm not asking you to code it for me, but I welcome feedback. If you think you can make it better or know of something better please share.
I know of Github it's overkill for me, I'm not comfortable, and I won't use it as much as I need to.
So here it is:
You place it in the source folder, open it in Scite.
Change: Global $gBackup_dir_path = "..\Backup\" to wherever you want you backup folder Path to be.
in the main() add some backup("file_name") calls remember to remove file extension.
and it should make a new backup file for each backup("file_name") every time you run the script.
Test it out make sure it's working and you're good to go.
#cs ---------------------------------------------------------------------------- AutoIt Version: 188.8.131.52 Author: myName Script Function: To copy files to a backup folder. #ce ---------------------------------------------------------------------------- #include <File.au3> Global $gBackup_dir_path = "..\Backup\" ; Todo ; Add notes, options notes in file name main() func main() ; File list remember to remove extentions from file_name ; or add file extention as second parameter backup("Map_Editor") backup("DW_Server") EndFunc Func backup($spFile_name, $spFile_ext = ".au3") Local $error = 0 Local $iFile_num = 0 ; Make source file path Local $sFile_path_source = $spFile_name & $spFile_ext Local $sFile_path_dest = "" ; Sample the contents of the backup directory before creating a file there Local $aFile = _FileListToArray($gBackup_dir_path, $spFile_name&"*"&$spFile_ext, $FLTA_FILES) $error = @error If $error = 0 Then $iFile_num = $aFile EndIf out("Found: " & $iFile_num & " files named: " & $spFile_name) Do ; Incroment file_num to find available file_name $iFile_num += 1 ; Path to Write File Copy $sFile_path_dest = $gBackup_dir_path & $spFile_name & "_" & $iFile_num & $spFile_ext ; Refuse to Overwrite File If FileExists($sFile_path_dest) = 0 Then ExitLoop EndIf ; Am I right? Sleep(30) Until 0 ; Create the file FileCopy($sFile_path_source, $sFile_path_dest, $FC_CREATEPATH) $error = @error If $error Then out("FileCopy() error: " & $error) out("sFile_path_source: " & $sFile_path_source & " sFile_path_dest: " & $sFile_path_dest) EndFunc ;==>backup Func out($output = "", $user = 0);debug tool ConsoleWrite(@CRLF & $output);to console new line, value of $output EndFunc ;==>out Backup_Script.au3
The script isn't authorized to overwrite files, and tries to create the next number of file_name available.
The 'p' in my variable names stands for parameter.