Adam1213 Posted May 15, 2006 Share Posted May 15, 2006 (edited) When compiled drag a file onto it to have it backed up to Backup<file>-<n>.<ext> or YYYY-MM-DD HH-MM-SS. It now supports mulitple files (v3.1) Backup.zip expandcollapse popup;___________________________________________________________ ;| | ;| Programed by Adam - http://adam1213.tk | ;|__________________________________________________________| global $currentworkingdir='-1' global $format_dt, $filedefault if $CmdLine[0] > 0 Then $file = '' for $i=1 To $CmdLine[0] $file=$CmdLine[$i] if $file<>'' then backup($file) next else $filedefault = IniRead("Backup\Settings.ini", 'Settings', "Default file", -1) if $filedefault=-1 then $filedefault='' IniWrite("Backup\Settings.ini", 'Settings', "Default file", $filedefault) else if $filedefault<>'' then backup($filedefault) endif endIf ;_____________________________ BACKUP ______________________________________________________ Func backup($file) If $file = @ScriptFullPath Then return 0 $dp = StringInStr($file, ".", 0, -1) If $dp > 0 Then $ext = StringMid($file, $dp + 1) if $ext<>'' then $ext = '.' & $ext $file = StringLeft($file, $dp - 1) Else $ext = '' EndIf $p = StringInStr($file, "\", 0, -1) global $workingdir = StringLeft($file, $p) $file = StringMid($file, $p + 1) if $currentworkingdir<>$workingdir then $currentworkingdir=$workingdir FileChangeDir($workingdir) DirCreate("Backup") ;______________________________ GET SETTINGS _________________________________________________ $filedefault = IniRead("Backup\Settings.ini", 'Settings', "Default file", -1) if $filedefault=-1 then $filedefault='' IniWrite("Backup\Settings.ini", 'Settings', "Default file", $filedefault) endif ;_____________________________________________________________________________________________ $format_dt = IniRead("Backup\Settings.ini", 'Settings', 'Date and time', -1) if $format_dt=-1 then $format_dt=0 IniWrite("Backup\Settings.ini", 'Settings','Date and time', $format_dt) endif endif ;_____________________________________________________________________________________________ if $file='' then MsgBox(0 + 16, 'Error', 'No file was specified') return (0) endif $cfile = $file&$ext if $format_dt=0 then $times = IniRead("Backup\Settings.ini", $cfile, "Times", 0) $times += 1 $id=$times else $id=@YEAR&'-'&@MON&'-'&@MDAY&' '&@HOUR&'.'&@MIN&'.'&@SEC endif $moveto ='Backup\'&$file&'-'&$id&$ext $bk = FileCopy($cfile, $moveto, 8) If $bk = 1 Then if $format_dt=0 then IniWrite("Backup\Settings.ini", $cfile, "Times", $times) return (1) Else MsgBox(0 + 16, "Error Backing up " & $file, '"' & $cfile & '" could not be copied to' & @CRLF & _ '"' & $moveto & '"') return (0) EndIf endFunc Edited December 22, 2006 by Adam1213 IRC Client - 75 pages 3728 lines. Blob crumbler (game)Backup (drag to backup + cmd line)RS232 Link to comment Share on other sites More sharing options...
Adam1213 Posted May 17, 2006 Author Share Posted May 17, 2006 What do people think of it? I am planning on adding support for multiple files it seams to give each file as a parement just the problem is that I dont know if i can still get the directory. Also I am planning on adding more support for file extensions..... I think there is a way of adding a backup option for everything just dont know how yet. "backup.exe" "file" is all that is needed to backup the file ... IRC Client - 75 pages 3728 lines. Blob crumbler (game)Backup (drag to backup + cmd line)RS232 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