#164703 - 2006-07-20 03:35 PM
Backup Script
|
Rooster10
Fresh Scripter
Registered: 2004-10-14
Posts: 14
|
Hi,
I am looking to run a script file which will search the current hard disk of the PC for file, example *.pst, *.doc, *.xls etc etc... then with the results send them to a destination ie a Server for example.
Basically a script which I can edit to change the destination address of the server for each customer, then run it.
Do you think this would be possible?, any ideas also to get me started?
Many thanks
Dan
|
|
Top
|
|
|
|
#164705 - 2006-07-20 03:40 PM
Re: Backup Script
|
Rooster10
Fresh Scripter
Registered: 2004-10-14
Posts: 14
|
Thanks for that, any chance of a couple of lines of code so I can get the idea?, very new to this, thanks
|
|
Top
|
|
|
|
#164706 - 2006-07-20 04:49 PM
Re: Backup Script
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
Dirlist will return an array of all the files you asked it to enumerate. With a for each--next loop you can split this array into seperate files and copy, rename, delete, etc… the file.
In the script below dirlists enumerates all .xls files ($xlsfiles), all .doc files ($docfiles) and all .pst files ($pstfiles) and then copy them one by one to a server. You should alter the destination path in the copy lines to match your environment.
!! BEWARE !! Enumerating entire drives could take some time and some of the files might be in use.
Code:
Break on ; Call @scriptdir = "\dirlist.udf" ; ;Enumerate all .xls, .doc and .pst files. $xlsfiles = DIRLIST("c:\*.xls",2+4) $docfiles = DIRLIST("c:\*.doc",2+4) $pstfiles = DIRLIST("c:\*.pst",2+4) ; ;Copy all .xls files. For Each $xlsfile in $xlsfiles Copy $xlsfile "\\server\share\" Next ; ;copy all .doc files. For Each $docfile in $docfiles Copy $docfile "\\server\share\" Next ; ;Copy all .pst file For Each $pstfile in $pstfiles Copy $pstfile "\\server\share\" Next ; ;!! DO NOT EDIT ANYTHING BELOW THIS LINE !! ;FUNCTION DirList ; ;AUTHOR Jens Meyer (sealeopard@usa.net) ; ;ACTION Returns an array with a list of files in a given directory ; ;VERSION 1.2 ; ;KIXTART 4.12 ; ;SYNTAX DIRLIST(DIRNAME [,OPTIONS]) ; ;PARAMETERS DIRNAME ; Required string containing the directory name ; ; OPTIONS ; Optional value for additional options, options are set bitwise ; 1 = include directories (denoted by a backslash) that match the search mask ; 2 = include full path ; 4 = search all subdirectories ; ;RETURNS array with a list of files, otherwise an empty string ; ;REMARKS none ; ;DEPENDENCIES none ; ;EXAMPLE $dirlist = DIRLIST("c:\*.*",1+2+4) ; ;KIXTART BBS http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000090 ; function dirlist($dirname, optional $options) dim $filename, $counter, $filepath, $mask dim $list, $sublist, $subcounter
$counter=-1
$dirname=trim($dirname) if $dirname='' $dirname=@CURDIR endif if right($dirname,1)='\' $dirname=left($dirname,len($dirname)-1) endif if getfileattr($dirname) & 16 $mask='*.*' else $mask=substr($dirname,instrrev($dirname,'\')+1) $dirname=left($dirname,len($dirname)-len($mask)-1) endif
redim $list[10] $filename=dir($dirname+'\'+$mask) while $filename<>'' and @ERROR=0 if $filename<>'.' and $filename<>'..' select case (getfileattr($dirname+'\'+$filename) & 16) if $options & 1 $counter=$counter+1 if $options & 2 $list[$counter]=$dirname+'\'+$filename+'\' else $list[$counter]=$filename+'\' endif endif if ($options & 4) $sublist=dirlist($dirname+'\'+$filename+'\'+$mask,4) if ubound($sublist)+1 redim preserve $list[ubound($list)+ubound($sublist)+1] for $subcounter=0 to ubound($sublist) $counter=$counter+1 if $options & 2 $list[$counter]=$dirname+'\'+$filename+'\'+$sublist[$subcounter] else $list[$counter]=$filename+'\'+$sublist[$subcounter] endif next endif endif case ($options & 2) $counter=$counter+1 $list[$counter]=$dirname+'\'+$filename case 1 $counter=$counter+1 $list[$counter]=$filename endselect if $counter mod 10 redim preserve $list[$counter+10] endif endif $filename = dir('') loop
if $counter+1 redim preserve $list[$counter] else $list='' endif
if $mask<>'*.*' and ($options & 4) $filename=dir($dirname+'\*.*') while $filename<>'' and @ERROR=0 if $filename<>'.' and $filename<>'..' if (getfileattr($dirname+'\'+$filename) & 16) $sublist=dirlist($dirname+'\'+$filename+'\'+$mask,4) if ubound($sublist)+1 redim preserve $list[ubound($list)+ubound($sublist)+1] for $subcounter=0 to ubound($sublist) $counter=$counter+1 if $options & 2 $list[$counter]=$dirname+'\'+$filename+'\'+$sublist[$subcounter] else $list[$counter]=$filename+'\'+$sublist[$subcounter] endif next endif endif endif $filename = dir('') loop endif
if $counter+1 redim preserve $list[$counter] else $list='' endif
$dirlist=$list endfunction
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1046 anonymous users online.
|
|
|