#!/bin/bash sfk script "$0" -from begin $@ exit function skip_block { sfk label begin -var -upat2 -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 source=project +setvar target=project2 // helper variables for short typing. // empty parms must be replaced by "-noop". +setvar s="#(sys.ownscript.name)" +setvar m="[Magenta]" +setvar d="[def]" +if "%1 = " begin +tell "[green]DataWay:[def] copy #(source) folders" +tell " #(m)FROM#(d) #(source) #(m)TO#(d) #(target)" +tell " #(m)WITH#(d) core desktop mobile doc" +tell " #(m)WITHOUT#(d) .svn old save, and some large 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 #(source) -using projdirs +stop +endif +if "#(begins(cmd,'size')) = 1" begin +setvar minsize=#(substr(cmd,4)) +if "#(minsize) = " setvar minsize=10 +treesize -minsize=#(minsize)m -root #(source) -using projdirs +stop +endif +if "#(cmd) = big" begin +big -root #(source) -using projdirs +stop +endif +if "#(cmd) = copy" begin +copy #(yes) #(source) #(target) -using projdirs +stop +endif +if "#(begins(cmd,'copy')) = 1" begin +setvar since=#(substr(cmd,4)) +copy -since #(since) #(yes) #(source) #(target) -using projdirs +stop +endif +if "#(cmd) = sync" begin +sync #(yes) -wipe #(source) #(target) -using projdirs +stop +endif +tell "unknown command: #(cmd)" +end // within label projdirs variables #() are not supported. // every parameter with whitespaces must be quoted by "". // -upat2 above allows unified syntax under linux/windows. // this will copy: project/core project/desktop ... // to copy whole project use: -dir . sfk label projdirs -dir core desktop mobile doc -subdir :/.svn :/old/ :/save/ ":/unused stuff/" :/tmpbin -file :.tmp :.tar :.tar.bz2 :tmp%.txt :.new :/a.out/ +end }