Home
Parent Directory

numoffiles

The program numoffiles looks for the number of (regular) files that are inside a directory.

If you have a lot of directories, each with one file inside (or example if you have used tools to automatically sort files into directories with tools like pftdbns or other tools, so that you possibly really have a lot of directories with) then this tool can help you to find out, which directories contain how much regular files.

The output has the following form:
dirname: number
you then can use the "cut"-command line tool to find out the names of the directories:
numoffiles -max 1 * | cut -d: -f1
and you can put the files to the current workeing directory and cleanup the dirs in this way:
for i in ` numoffiles -max 1 * | cut -d: -f1` ; do mv $i/* .; rmdir $i; done

To automatically sort the files in the current working directory by namestructure, but putting all files that are not depending to one group of files, you might use this:
pftdbns *; for i in ` numoffiles -max 1 * | cut -d: -f1` ; do mv $i/* .; rmdir $i; done; pftdbns -fd _single-files_ *
or possibly even better (Attention! if it is better depends on the filenames that are actually in your dir!):
/usr/bin/ls | namealign -minint; pftdbns *; for i in ` numoffiles -max 1 * | cut -d: -f1` ; do mv $i/* .; rmdir $i; done; pftdbns -fd single-files *



Mail: oliver _at_ first.in-berlin.de

last time changed: 19th of July 2007