Swiss File Knife
a command line
free external tools,
- download the free Swiss File Knife Base from Sourceforge. - open the Windows CMD command line, Mac OS X Terminal or Linux shell. - OS X : type mv sfk-mac-i686.exe sfk and chmod +x sfk then ./sfk - Linux: type mv sfk-linux.exe sfk and chmod +x sfk then ./sfk OS X and Linux syntax may differ, check the help within the tool.
sfk general options reference: Please note: some of these options are supported only by some commands. -var insert SFK variables by using #(varname). type this option directly after "sfk" to use it globally with all commands in a chain or script. to print "#(" literally then escape it like ##( -upat unix compatible file or text selection and patterns. allows to use -subdir :/tmp instead of !\tmp, filter -:foo instead of -!foo and run "#file" instead of "$file", to create unified .sh batch files for Windows and Linux. -upat2 same as -upat but also support wildcard % instead of * you may also set this by an environment variable like: set SFK_CONFIG=upat2 -nosub or -norec does not include subdirectories (subfolders). processing of subdirs is DEFAULT with most commands, therefore you must specify -nosub to switch it off. -withsub include subdirs. is DEFAULT with most commands. -verbose print additional infos while running a command. helpful if a command doesn't work as expected. only some commands support -verbose. try also -verbose=2. -nofollow or -nofo does not follow symbolic directory links. this option may NOT work with older Linux versions, esp. those needing the "lib5" binary version of sfk. -quiet reduce output on some commands. e.g. the find command will not display the "scan" status info while searching files. -quiet=2 reduce output even more on some commands. -memcheck check memory list at the end of every command to detect overwrites. reduces performance. -debug print extra program flow infos to track errors. also activates -memcheck under Windows. -nohead no not list header/trailer info on some commands: the run cmd will not tell "simulating" even if it's in simulation mode. -case activate case sensitive text comparison with some commands. most text processing commands are case-insensitive by default. filename comparison is always case insensitive. -hidden include hidden and system files. -nohidden exclude hidden and system files. -yes fully execute the command. some commands like "run" are running in simulation mode by default, to avoid damage to your files, as long as you're unsure which files and dirs to select. as soon as you add -yes, however, everything is fully executed. -minsize=s select only files >= size, like 10b or 100k -maxsize=s select only files <= size, like 10m or 4g b=bytes k=kbytes m=megabytes g=gigabytes=10^9 bytes K=2^10 bytes M=2^20 bytes G=2^30 bytes -weblimit=n change web access download limit to n mbytes, with functions like sfk web, filter, xex. default is 30 mb. you may also set SFK_CONFIG=weblimit:20 -webtimeout=n web access timeout in msec. default is 10000. you may also set SFK_CONFIG=webtimeout:3000 -headers print http headers with commands accessing the web. -textfiles process only text files, no binaries. -text is the same, but this may interfere with some command's local -text option. text/binary detection only checks the file's first 4 kbytes. -binfiles process only binary files. -bin is the same, but this may interfere with some command's local -bin option. -umlauts with binary-to-text conversion, include german characters. -nocol disable all colored output. important if your shell has a background color incompatible to the default color scheme, or (under linux) if the sfk output text must be processed further through pipelining, and needs to be stripped from the color escape sequences. -col switch on colored output. "sfk help colors" for more. -html dump sfk help text (color control) in html format. -html must be typed directly after "sfk". -htmlpage the same, but include a header to view it in a browser. -sincedir or -sincedif/add/chg: compare directory tree against a reference tree, process only changed or added files. see "sfk list" for details. -tracesel give verbose infos why directories and files have been selected or excluded. -tracedirs lists only directories, -tracefiles lists only files. -since process only files changed on or after the supplied date/timestamp. "sfk list" for details. -before process only files changed before that date/timestamp. -flist fn or "-fl fn" reads list of filenames from file fn. -spat activates interpretation of slash patterns: \t=TAB \q=" \r=CR \n=LF \\=\ \xnn=any char w/hex code nn with some commands like replace, filter -form and -replace. -literal or -lit disables interpretation of wildcards * and ? and slash patterns, if they were activated previously. -nospat disables only slash patterns. -nocconv when printing output to the windows console, sfk tries to convert umlaut and accent characters to display them correctly with codepage 850. set -nocconv to disable this. whenever output is redirected to file, no conversion is done. -cconv force codepage conversions: if command output is redirected to a file, codepage conversion is disabled by default. use this option to activate, e.g. when post-processing sfk run output which produced filename lists. -noipex disable automatic IP expansion with some commands. -arc read contents of well known zip, tar.gz and tar.bz2 archives as deep as possible, including nested archives. well known archives must have one of these extensions: .zip .jar .ear .war .aar .xpi .tar .tar.gz .tar.bz2 .tgz .gz .bz2 .odt .ods .odp .odg .odc .ott .ots .otp .otg to include further extensions, read below about SFK_ZIP_EXT. this binary (SFK Base/XD) can read only the first 1000 bytes of every archive entry. listing of contents is not limited. type "sfk help xe" for all details and restrictions. -xarc read contents of any zip file, regardless of file extension, and tar.gz and tar.bz2 files. reads the first bytes of every file and will therefore perform slower then -arc. -wchar activate EXPERIMENTAL utf-16 (ucs-2, wide char) decoding, allowing sfk find or filter to search text in utf-16 files. should not be used when (re)writing files. get more infos by typing "sfk help unicode". -to mask specify where to write output files with some commands. mask supports $file, $path, $base, $ext and more, like -to outdir\$base-modified.$ext say "sfk run" for a list of possible keywords. -tofile x specify a single output filename, which is taken as is and not checked for any $ patterns. -tomake .ext select only files that have no, or an older, counterpart file with extension .ext in the same folder. -tomake outdir\$base.ext select only files that have no or an older counterpart file in outdir with extension .ext. see "sfk run" for example: .wav to .mp3 conversion -tmpdir x set directory x as temporary file directory. default is to use the path specified by TEMP or TMP env variable. -showtmp tell verbosely which temporary files are created. -keeptmp do not delete the temporary files, if possible. -nowarn and -noerr, -nonote disable warn, error and note messages. -memlimit=n set the caching memory limit to n mbytes (default=300). used if a function needs to load whole files into memory. if zip etc. archive processing is very slow, it may be caused by a cache overflow. try to increase the -memlimit then. if you think sfk uses too much memory while processing files, try to reduce -memlimit (values below 200 are not recommended). you may also set SFK_CONFIG (see end of this text). -cachestat tell amount of memory used by archive file cache. -nocache disable the disk cache (for network files). -exectime tell command execution time at program end. -noesckey disable stop by escape key. (windows only) shell return code handling and error processing: -showrc print sfk return code at program end. may not print anything in case of fatal errors, like wrong syntax (usually rc 9). -exterr in case of operating system related errors like file access, prints extended error information, if available. -waitonerr wait for user input on every error. -waitonend wait for user input at program end. -stoponerr stop directory tree processing on first unreadable file. default is to process as many files as possible, skipping unreadable files and directories. -rcfromerr some commands like filter, find, hexfind tell by shell rc that something was found. by default, skipped errors like unreadable files do NOT change this rc. with -rcfromerr, skipped errors do override the resulting shell rc. -echoonerr echo whole command to stderr when an error occurs. see also the SFK_CONFIG setting "echoonstart" below. to experiment with the above options, try "sfk errortest". command local versus global scope: within a command chain, many options have an effect only locally with the command where they are specified, e.g. in sfk filt x.txt -case -high red FooCase +filt -high blue TheBar the "-case" is valid only for the first filter command. but the following options can also be used globally, if specified directly after "sfk": -nohead -noinfo -nofile -case -literal -spat for example, in sfk -case filt x.txt -high red FooCase +filt -high blue TheBar the "-case" is valid for ALL commands in the command chain. environment configuration: set SFK_CONFIG=columns:n,active-file-age:n,memlimit:n,... columns: sfk (for windows) tries to autodetect the no. of console columns, but you may also set this value through this config parm. active-file-age:n some functions need to tell if a file is 'recently edited' or rather old and inactive. by default, files > 30 days of age are considered non-active. reconfigure the no. of days threshold here. memlimit: set memory limit to n mbytes. echoonstart: echo the whole sfk command on start, to stderr. echoonerr: echo the whole sfk command on errors, to stderr. tmpdir:path set folder for temporary files, used by some commands. e.g. set SFK_CONFIG=tmpdir:d:\tmp,memlimit:500 set SFK_ZIP_EXT=".foo .bar .myext" set additional, user defined zip file extensions. in this example, files ending with .foo, .bar or .myext are also treated as zip files. for the list of default extensions, look above at the -arc option.
sfk is a free open-source tool, running instantly without installation efforts. no DLL's,
no registry changes - just get sfk.exe from the zip package and use it (binaries for
windows, linux and mac are included).
read more about all sfk functions here.