On 5/7/14 at 2:44 AM, d...@gmail.com
>Here's a related real-live problem:
>list all files in Dir-tree:D | which are less-than daysOld:N | and
>contain "egal" in the FullPathName | and contain String:"uid" OR
It is not entirely clear what it is you are trying to do. There
are a couple of ways to obtain a list of files in a given directory.
First, if the directory is the current working directory, then
will return a list of every thing at the top level of the
directory. But in this case, only the name of things at that
level are returned not the path name.
If the directory is a subdirectory of the current working
directory you can get a list of files in that directory with
This will return a relative path name, relative to the current
If you want the full path name then using the last form above
with dirname specified with the full path name will give you
what you want.
I will assume the desired files are in the current working
directory and you want any file with "egal" in the path name at
any sub directory level with those assumptions the problem above
can be solved as:
The FileType portion filters out directories, the Subtract@@
portion computes the age of the file in days and compares that
to a specified age and the FindLIst portion looks to see if the
file contains either "UID" or "uid".
Cases checks each file for the three conditions above and only
returns a those that meet all three conditions.
Note, while this isn't a difficult thing to do in Mathematica,
if all you need to do is solve this class of problem, i.e.,
something were you need a list of files meeting a specified
criteria, Mathematica really is overkill and an expensive way to
solve this class of problem.
What Mathematica can do with files is all kinds of sophisticated
numerical analysis on the file contents, analysis that could be
very time consuming to implement in something such as Perl,
It makes sense to solve this class of problem within Mathematica
when you already have a license to Mathematica, are familiar
with Mathematica and solving this problem is merely a subset of
a larger problem. But it definitely does not make sense to me to
buy a license for Mathematica for just the ability to locate
files in this manner. There are far less expensive solutions for
Another thing to consider. I've been using Mathematica since
version 1.2 and pretty much on a daily basis since version 3.0.
I consider myself quite proficient using Mathematica to solve
problems I encounter. But despite using Mathematica extensively
for quite a number of years, I do not see myself as fully
mastering Mathematica. And the level of proficiency I have
achieved was not achieved in a few days or a few weeks.
Mathematica is extremely versatile and is a very rich toolset
for solving a large variety of programs. But that versatility
comes at a price. Mathematica has what I would consider a rather
steep learning curve to climb before proficiency is achieved.