@echo off sfk script -anyparms "%~f0" -from begin %* rem %~f0 is the absolute batch file name. rem %* passes through every parameter given. rem -anyparms allows words starting with '+'. GOTO xend sfk label begin -var -checkdirs // Selective file copy example. Just run this batch for infos. // Read detailed explanations of every step in the SFK e-Book, // under "Backup and transfer of folders". +setvar cmd="%1" +setvar yes="%2" +setvar target=R:\backup // helper variables for short typing. // empty parms must be replaced by "-noop". +setvar s="#(sys.ownscript.name)" +setvar m="[Magenta]" +setvar d="[def]" // if "view" or "+view" is given with list, size, or big // then insert a variable command to view all output // comfortably and searcheable with Depeche View. +setvar todview="" +if "#(contains(yes,'view')) = 1" setvar todview="+view" +if "%1 = " begin +tell "[green]DataWay:[def] PC Backup" +tell " #(m)FROM#(d) C: and D: #(m)TO#(d) #(target)" +tell " #(m)WITH#(d) org app work mail" +tell " #(m)WITHOUT#(d) cache save, and tmp files" +tell " " +tell "[green]Usage:[def]" +tell " #(s) command" +tell " " +tell "[green]Commands:[def]" +tell " #(m)list#(d) - list all selected source files." +tell " press escape or ctrl+c to stop." +tell " #(m)size#(d) - tell size of source folders," +tell " list 50 mb blocks and larger" +tell " #(m) size200#(d) - list 200 mb blocks and larger" +tell " #(m)big#(d) - show biggest selected source files" +tell " " +tell " #(m)copy#(d) - simulate copy to #(target)" +tell " #(m) copy -yes#(d) - really copy to #(target)" +tell " " +tell " #(m)copy7d#(d) - copy only files created or changed" +tell " in the last 7 days" +tell " " +tell " #(m)sync#(d) - simulate copy with DELETE of files" +tell " in #(target) which do not exist" +tell " in the source folders" +tell " #(m) sync -yes#(d) - really sync to #(target)" +stop +endif // "-using" allows to use the same file set in multiple commands. // "-root" is a prefix for every -dir entry within -using. +if "#(cmd) = list" begin +dir -time -size -root C:\ -using cdirs -root D:\ -using ddirs #(todview) +stop +endif +if "#(begins(cmd,'size')) = 1" begin +setvar minsize=#(substr(cmd,4)) +if "#(minsize) = " setvar minsize=10 +treesize -minsize=#(minsize)m -root C:\ -using cdirs -root D:\ -using ddirs #(todview) +stop +endif +if "#(cmd) = big" begin +big -root C:\ -using cdirs -root D:\ -using ddirs #(todview) +stop +endif +if "#(cmd) = copy" begin +copy #(yes) C:\ #(target)\c -using cdirs +copy #(yes) D:\ #(target)\d -using ddirs +stop +endif +if "#(begins(cmd,'copy')) = 1" begin +setvar since=#(substr(cmd,4)) +copy -since #(since) #(yes) C:\ #(target)\c -using cdirs +copy -since #(since) #(yes) D:\ #(target)\d -using ddirs +stop +endif +if "#(cmd) = sync" begin +sync #(yes) -wipe C:\ #(target)\c -using cdirs +sync #(yes) -wipe D:\ #(target)\d -using ddirs +stop +endif +tell "unknown command: #(cmd)" +end sfk label cdirs // copy C:\org C:\app etc. // variables #() are not supported. // every parameter with whitespaces must be quoted by "". -dir org app "Users\All Users\VirtualBox" -subdir !\cache\ !\save\ "!\unused stuff\" -file !.tmp +end sfk label ddirs // this will copy: D:\work D:\mail -dir work -subdir !\.svn !\old\ !\save\ -file !\tmp*.* !.tmp !.bak -dir mail -subdir !\cache +end :xend