How to do things
AI Noob vs. Pro
List biggest files
List newest files
Show subdir sizes
Search in files
Replace word in files
List dir differences
Send files in LAN
Free Open Source:
Swiss File Knife
a command line multi function tool.
Depeche View
Source Research
First Steps
windows GUI automation
command line
file encryption
free external tools,
zero install effort,
usb stick compliant:
cpp sources
articles
 |
How to load all text files from a directory, and subdirectories, matching given filename and directory name patterns
How to include or exclude files to load by name, extension,
or sub directory name, with a Freeware tool for Windows and Linux/Mac.
After download, run the tool by double click, then click on Open
and select a directory from which you want to load all text files.
All ASCII text files from that folder will be loaded, like all
.txt, .ini, .html, readme or source code files.
how to load only specific file types
By default, if you open or a directory in Depeche View,
ALL text files from within that directory tree will be loaded.
In many cases, this is too much. Especially when searching
in a huge source code base, you may want to load all .java
or .cpp files, but not every .xml or .tmp file.
This can be achieved
1. by the file loading filters and options dialog
2. or by running dview from the command line
3. or by creating fileset definitions.
file loading filters and options dialog
Click on the four-light button right next to "open",
or select Setup / Workspace.
The file loading options dialog appears, which is basically
self-explaining: hoover the mouse over any element,
and read the local help text shown under "additional infos".
Short summary of the most important fields:
- if you want to load ONLY files containing some word
in their filename, enter the list under
"load only from filenames", separated by blanks.
if you want to EXCLUDE files containing some word,
list them prefixed by "!". for example:
.cpp .hpp .java !.tmp !.bak !.save
loads foobar.cpp and goo.java but NOT foobar.bak
- if you want to EXCLUDE subdirectories containing
a word in the directory name, make a list of words
prefixed by "!", e.g.
!tmp !save
excludes all files from "tmp", "tmp1", "tmp100"
and "save" directories.
loading filter examples
Under Setup / Workspace, you can configure which files
or sub folders to include while loading, and which not.
File exclusion by filename:
!foo -> exclude all files like *foo*
!\foo -> exclude starting with foo
!foo\ -> exclude ending with foo
!\foo\ -> exclude exactly foo
!.foo -> exclude extension foo
File inclusion by filename:
foo -> include all files like *foo*
\foo -> include starting with foo
foo\ -> include ending with foo
\foo\ -> include exactly foo
.foo .bar -> select only .foo and .bar files
Combined file mask example:
.hpp .cpp !bak !\save !\readme.hpp\
-> load only .hpp and .cpp files,
exclude for example foo-bak.cpp
and files starting like save,
exclude files called exactly readme.hpp
Sub directory exclusion examples:
!foo -> exclude subdirs like *foo*
!.foo -> exclude with extension .foo
!\foo -> exclude starting with foo
!foo\ -> exclude ending with foo
!\foo\ -> exclude exactly foo
!\foo\bar\ -> exclude subdir combi
!*.foo* -> exclude with .foo anywhere
Sub directory inclusion (white listing) examples:
foo -> include paths having *foo*
\foo -> include paths having *\foo
foo\ -> include paths having *foo
\foo\ -> include paths exactly foo
.foo -> include with extension .foo
\foo\bar\ -> include subdir combi
Combined dir mask example:
source \include !.svn !\tmp !\save
-> load only from sub folders having source in their name
or which start like "include", excluding all sub folders
with extension .svn or starting like tmp or save.
all command line options
Depeche View uses the Swiss File Knife file selection syntax:
- loads whole directory trees by default,
i.e. includes sub directories without an extra option
- does not require wildcards in most cases,
as "*" is implied around every plain text word.
i.e. "foo" by default means "*foo*".
- very flexible selection of dirs, subdirs, and files.
short format:
dview [options] singleDirName [filePattern1 filePattern2 ...]
long format:
dview [options] -dir mydir1 [-file fpat1 ...] -dir mydir2 ...
The available options are:
-area ... set absolute startup window location and size
-space ... set relative startup window location and size
for details see display area size and location.
-max start maximized, covering the whole desktop.
-lean start with non maximized width, in isolated view mode
(without a master frame, without pull down menu).
as long as there is no second window, the initial one
can be maximized by F1.
-noassist disable assistance mode popups.
-clean disable assistance mode, and scrollbars in vertical tiling.
-assist activate assistance mode.
-edit Pro: if only a single file is loaded, enter edit mode.
-isolated starts with isolated frame mode. you may also use "-iso".
-overscan starts with isolated overscan mode. may also use "-over".
-verbose during startup, tell in the message log in detail which
root dirs, dir masks and file masks have actually been
selected for loading. helpful to analyze why some files
are loaded, and others not. the output may differ slightly
from what you specified, for example "*" file masks may be
added automatically if you only supplied an "!" exclusion,
or ".zip" file masks may be converted into path masks
(i.e., dir masks starting with "*").
-withsub load subdirectory contents
(default if not disabled by Setup).
-nosub do not load subdirectory contents.
-hidden also load all HIDDEN or SYSTEM files (not default).
helpful if you need to search through configuration files,
for example of your web browser.
-allbin also load all binary files (extracting text parts).
-wrap[=n] wrap long text lines at current screen width, or column n.
-wrapbin=n wrap text extracted from binary files at column n.
-arc Pro: load contents of .zip .jar .ear etc. archives
and also .gz, .bz2, .tar, .tar.gz and .tar.bz2
as deep as possible, including nested archives.
-qarc Pro: quick load archives, load only archive entries
at the top level, skipping nested archives.
-since load only files changed since this timestamp, e.g.
"2006-01-31 12:15:59" or 20060131121559
2006-01-31 or 20060131
today : files changed since midnight of today
1d : changed since 1 day, i.e. not counting
from midnight, but 24 hours into the past
5h, 30m, 10s : 5 hours, 30 minutes, 10 seconds.
-before load files modified before that timestamp.
-today short replacement for "-since today".
-usectime use creation time instead of modification time.
may not be available on some filesystems.
-sincedir compare against another directory, load files that
have been added, have different time, or content.
-sinceadd like -sincedir, load only added files.
-sincedif like -sincedir, load only changed files.
does not load files with diff. time but same content.
does not load added files.
-sincechg load files with different content, and added files.
does not load files with diff. time but same content.
-umlauts with binary-to-text conversion, include german characters.
-flist fn or "-fl fn" reads list of filenames from file fn.
-fileset x use a fileset definition. more on that below.
-utf load also utf-16 (ucs-2, wide char) file contents.
this option is experimental, and will only extract
plain ASCII text contents from those files.
-memlimit=n set the caching memory limit to n mbytes (default=300).
if zip etc. archive processing is very slow, it may be
caused by a cache overflow. try to increase -memlimit then.
details of filename / extension selection:
- when specifying a filename pattern beginning with a dot "."
and no wildcard, only files with this extension will be selected.
- otherwise the pattern is searched anywhere within the filename.
to force a filename start comparison, say \pattern (with a slash).
- filename means the relative filename, not directory or path name.
command line file selection examples
dview foodir .txt .hpp .cpp
loads all .txt, .hpp and .cpp files from the directory tree foodir,
including all subdirectories. this is the short file selection syntax,
with ONE directory name, and MANY file patterns.
dview -nosub -today foodir
loads all text files from foodir that have been changed today,
however excluding sub direcory contents.
dview -dir foodir1 foodir2 foodir3 !\save !.svn -file .txt
loads all .txt files from the root directories foodir1,
foodir2 and foodir3, except those in sub directories
starting like "save" or having an .svn extension.
dview -dir foodir1 -file .h .c -dir foodir2 -file .txt !.tmp.txt
loads all .h, .c and .txt files from foodir1 and all .txt files
from foodir2, however excluding all files from foodir2 ending
with ".tmp.txt". this is the long file selection syntax,
supporting any number of directories and any number of file patterns.
dview -arc -dir foo1.zip foo2.tar.bz2
Pro: loads all text files from foo1.zip and foo2.tar.bz2.
note that archive files are treated as directories.
by default, archive files embedded within the listed
archive files are loaded as well.
dview -arc -dir foo1.zip foo2.tar.bz2 -file .txt .js .cc
Pro: loads .txt, .js and .cc files from the archives
foo1.zip and foo2.tar.bz2. in this case, the same
file filter is used for both directories.
dview -arc -dir foo1.zip -file .txt -dir foo2.tar.bz2 -file .cpp
Pro: load all .txt from foo1.zip, and all .cpp from foo2.tar.bz2.
in this case, separate file filters are used per directory.
Long -dir ... -file ... format further examples:
to load from multiple root directories:
-dir rootdir1 rootdir2 ... -file .cpp .hpp .txt ...
to include or exclude contents of sub directories
within the given root directories, use:
wide sub dir selection syntax:
-dir . -subdir !foo -> exclude subdirs like *foo*
-dir . -subdir !.foo -> exclude with extension .foo
-dir . -subdir !\foo -> exclude starting with foo
-dir . -subdir !foo\ -> exclude ending with foo
-dir . -subdir !\foo\ -> exclude exactly foo
-dir . -subdir !\foo\bar\ -> exclude subdir combi
-dir . -subdir !*.foo* -> exclude with .foo anywhere
-dir . -subdir foo -> include paths having *foo*
-dir . -subdir \foo -> include paths having *\foo
-dir . -subdir foo\ -> include paths having *foo
-dir . -subdir \foo\ -> include paths exactly foo
-dir . -subdir .foo -> include with extension .foo
-dir . -subdir \foo\bar\ -> include subdir combi
... instead of -subdir, you may also type just -sub
compact sub dir selection syntax:
-dir . !foo -> exclude subdirs like *foo*
-dir . !.foo -> exclude with extension .foo
-dir . !\foo -> exclude starting with foo
-dir . !foo\ -> exclude ending with foo
-dir . !\foo\ -> exclude exactly foo
-dir . !\foo\bar\ -> exclude subdir combi
-dir . !*.foo* -> exclude with .foo anywhere
-dir . *foo* -> include paths having *foo*
-dir . *\foo -> include paths having *\foo
-dir . *foo\ -> include paths having *foo
-dir . *\foo\ -> include paths exactly foo
-dir . *.foo -> include with extension .foo
-dir . *\foo\bar\ -> include subdir combi
... as you can see, when using the compact syntax,
sub directory inclusion masks require a wildcard "*"
in their name, to make sure they're not interpreted
as root directory names.
In the Setup / workspace settings, "*" is not required
around sub directory filters, as there are no ambiguities.
exclusion by filename:
-file !foo -> exclude all files like *foo*
-file !\foo -> exclude starting with foo
-file !foo\ -> exclude ending with foo
-file !\foo\ -> exclude exactly foo
-file !.foo -> exclude extension foo
inclusion by filename:
-file foo -> include all files like *foo*
-file \foo -> include starting with foo
-file foo\ -> include ending with foo
-file \foo\ -> include exactly foo
-file .foo .bar -> select .foo and .bar files
Typical errors in command line file selection
BAD: dview -arc foo1.zip foo2.tar.bz2
-> this actually means: load all files having foo2.tar.bz2
in their name from foo1.zip, and it will not load anything.
use "dview -arc -dir foo1.zip foo2.tar.bz2" instead.
BAD: dview -nosub -arc -dir foo1.zip
-> exclusion of subdirectories is not supported within archive
files. however, if you want to disable the processing
of archives embedded within archives, you may use
"dview -qarc -dir foo1.zip"
BAD: dview -arc -dir . *.xpi *mysrc.tar.bz2
-> the intention is to load only contents from .xpi files
and mysrc.tar.bz2. however, if many other archive files
are present within the current directory ".", dview
will SCAN THEM ALL, searching for files embedded within
ANY archive having ".xpi" or "mysrc.tar.bz2" in their name.
so, the command must be rewritten to list the exact names
that should be loaded, like
dview -arc -dir foo1.xpi foo2.xpi foo3.xpi mysrc.tar.bz2
Whenever in doubt, use option -verbose to see in the message log
what DView really tries to load.
defining filesets
Another way is to define "file sets", which are text files containing:
- directory names to include or exclude
- filename patterns or extensions to include or exclude
example:
-------- file mywork1.txt begin ----------
# within this directory tree
-dir mysrc\baselib
# take only .h .c .txt files
-file .h .c .txt
# within this directory tree
-dir mysrc\foobank
# exclude all save and tmp dirs
!\save\
!\tmp\
# then take only .hpp and .cpp files
-file .hpp .cpp
# from this directory tree
-dir "C:\Docs With Blanks"
# take all files except .bak and .tmp
# and except names containing "old stuff"
-file -all !.bak !.tmp "!old stuff"
-------- file mywork1.txt end ----------
As you may guess, lines having '#' as first character are remarks,
and names containing blanks must be surrounded by double quotes "".
using workspace definitions from the command line
So the above fileset defines 3 directories, and what to load
and not to load from those directories. Now copy the above
text into a file "mywork1.txt", then run dview from the command line:
dview -fileset mywork1.txt
And dview will load the text files as defined in mywork1.txt.
Even faster: produce a snapfile from the above fileset definition,
which is a collection of text files, then load that at high speed.
Find more on that under reducing load times.
using workspace definitions when starting by icon
You may also create a Depeche View Icon on the desktop,
via the Icon button, then open the Icon properties,
and change the Icon's "target" field. For example,
if dview is located in C:\app\bin, you may change it to
C:\app\bin\dview.exe -fileset mywork1.txt
Then, a double click onto that icon will load that workspace.
bookmark filename definition with filesets
When using filesets, what will be the bookmark filename?
Just as if you say "-dir mydir1 -dir mydir2" on the commandline,
the first directory tree will be taken to build the bookmark
file base name, all others will be ignored.
In the example
-dir mysrc\baselib
-file .h .c .txt !.hpp !.cpp
-dir mysrc\foobank
-file .hpp .cpp
-dir mysrc\formats
-file -all !.bak
the bookmark filenames would be
mysrc\zz-baselib-bookmarks.1.dvbm
mysrc\zz-baselib-bookmarks.2.dvbm
mysrc\zz-baselib-bookmarks.3.dvbm
...
If you want to load bookmarks from somewhere else, read more here.
using plain filename lists
Sometimes you may want to load files whose names are listed in a
simple text file, called a file list. This can be done by
dview -flist names.txt
loading text extracts from binary files
By default, dview skips all binary file contents. But sometimes
it might be interesting to take a peek into binary files, e.g.
to search through meta informations in (smaller) media files.
To do so, you can
- click on the load options button right next to "open",
then check "load text from binary files".
- OR: click "open / load text from a single file", then select
a single binary file. this way you don't have to check
the "load text from binary files" option.
- OR: run dview from the command line,
supplying a single binary file name
- OR: run dview from the command line,
with option "-allbin" and a directory name, e.g.
dview -allbin mydir
In all these cases, dview tries to identifiy readable text informations
from binary files, which may or may not produce anything useful.
loading hidden and system files
Hidden files and directories are, as the name implies, invisible,
so the directories do NOT appear in the Open dialogue, and their
contents are NOT loaded, even if you load a surrounding directory.
But sometimes it is helpful to load also hidden files.
For example, if your Firefox browser behaves unexpected,
it is very helpful to take a deeper look into its configuration files,
especially "prefs.js". But where are those files?
Under Windows XP, they are somewhere below
C:\Documents and Settings\userid\Application Data\Mozilla\Firefox\ ...
But, to repeat, because "Application Data" can be a HIDDEN folder
already, it may NOT appear within the Open dialogue.
So try exactly these steps:
1. click on the load options button right next to "Open",
check "include hidden and system files", and close Setup.
2. select "open / load all text from a folder".
3. click into the "folder" text entry field at the bottom.
(may not work under Linux, as the WINE dialog might be limited)
Now type MANUALLY:
- C:\documents and settings\
- then your userid and "\"
- then "application data\"
as soon as you type the "\", the Open dialog will offer you
further directories within the hidden folder!
- now type "mozilla\firefox"
and finally press ENTER. so the whole path would be
C:\documents and settings\yourUserID\application data\
mozilla\firefox
4. dview will load all config files of firefox.
5. type "prefs.js" into the PATH: field.
Now you should see what the startup config of Firefox is.
Another way: use dview from the command line
The command
dview -hidden -dir "C:\documents and settings" "*firefox*"
Does the following:
- walk through all normal and hidden files within
"C:\documents and settings",
including all (hidden) subdirectories.
- but load only files having "firefox" in their path.
(*firefox* is called a "path mask" in dview, identified
by the wildcards.)
excluding subdirectory contents during load
By default, if you select a folder through the Open button,
dview loads the files from that folder and all its subdirectories.
If you do NOT want to include subdirectory contents,
- click on the load options button right to "open".
- disable "include subdirectory contents" and close Setup.
On the next Open or Append operation, subdirs will be excluded.
When running dview from the command line, use option "-nosub".
|