Download: fnumfilt.tgz (20061001)
fnumfilt is a linux/posix tool that helps me processing lists of images made with my digital camera.
The images of my cam have the format "r<7-digits>.jpg". Often I want to process just some of the images. With fnumfilt, I can filter number ranges extracted from the filenames, and print resulting lists or execute a tool like convert (ImageMagick) to easily create thumbnails.
The following three chapters are the output of fnumfilt -C, fnumfilt -h and fnumfilt -H. I hope they help you deciding whether this's a tool for you.
Numfilt is GPL software. You're free to use it. But you use it on your own risk.
If you want to contact me, please write to
Change history of program fnumfilt V1.2: 2006-10-01: 1.2: Renamed program to 'fnumfilt', because there's another numfilt out there. Changed -x to always print the executed command. Fixed conflict in -o/-x. -x is now independent. 2004-05-06: 1.1: Added option "-x" to make fnumfilt execute the output ("-O") as shell command. Added option "-C" to show the changes history. Added version variable. Added many comment lines. 2004-04-29: Coded the program. Extensive testing. Release. 2004-04-28: Had the idea and began to code.
fnumfilt V1.2 (C) by T.Kloppenburg, released under the GPL [-h] : this help [-H] : more help (examples) -> fnumfilt -H | less -S [-C] : show change history of the program. -r "5-40 -15-201 18" : set number range [-i <file>] : read filenames from file (default: stdin) [-I x%07d.jpg] : set input format to x + 7 digits + .jpg (default: any digits) -o <file> : output result into file (default: stdout) -O "formatstring" : output data string (...) Placeholders: %FNAME %FPATH $PATH %NUM %COUNT -J %07d : number format for -O, %07d = 7 digits, leading zeros. -c : generate faked filenames: count in range_min..range_max [-n <int>] : set offset for %COUNT (see -O "formatstring") -a : print all lines (good in some special cases, see -H page) -d : print informative debug messaged -x : execute command given with -O "formatstring". Dangerous!!! USE IT ON YOUR OWN RISK! BE CAREFUL!
This is the "more help" page :). Some examples for fun and profit: 1. We have made thousands of photos with our digicam. They are in /data/digicam/20040429/. They look like "r0001324.jpg". We want to have convert command calls to generate thumbnails of photo 0001324-0001350, but not the photos 0001340 to 0001345 (aunt mary!). # ls /data/digicam/20040429/*jpg | ./fnumfilt -r "1324-1350 -1340-1345" -I "r%d.jpg" -O "convert -scale 120x %FPATH thumbs/th_%FNAME" this will generate a list if lines like: convert -scale 120x /data./../r0001324.jpg thumbs/th_r0001324.jpg ... but no lines for r0001340.jpg up to r0001345.jpg ! 2. You have hundreds of thumbnail files and you want to have a simple index web page with links to the big images. But not number 1201-1205 (you, naked!): ls /data/thumbs/*jpg | fnumfilt -r "-1201-1205" -O "<a href="/gfx/%FNAME"><img src="/thumbs/th_%FNAME"></a><br>" 3. Printing "convert" commands is one thing, calling convert another: ls r*jpg | ./fnumfilt -r "10763-10780" -O "%FNAME th_%FNAME"| xargs convert -scale 100x This calls "convert" with like this: convert -scale 100x r0010763.jpg th_r0010763.jpg convert -scale 100x r0010765.jpg th_r0010765.jpg ... This didn't work on some of my machines, so I added a "-x" option. The -x option tries to start the -O output as command! ATTENTION: You may destroy your system or delete important data! USE IT ON YOUR OWN RISK! BE CAREFUL! 4. You want to generate numbers: fnumfilt -c -r "10-20 -15-17 -12-13" # -c = use number generator 10 11 14 18 19 20 ./fnumfilt -c -r "10-20 -15-17 -11-12" -J "%05d" -O "%NUM" 00010 00013 00014 00018 00019 00020 (-I defines the input filter. It is an ugly hack to use it as output format string...) I messed /var/log/messages up: morx:/var/log # ls messages-20040* messages-20040310.gz messages-20040429 messages-20040501 messages-20040503 messages-20040406.gz messages-20040430 messages-20040502 messages-20040504 The .gz files are real world files. The others are fake and I want do delete them: morx:/var/log # ls messages-20040*| /home/tapo/lang/fnumfilt/fnumfilt -r "20040429-20040504" -O "rm /var/log/%FNAME" rm /var/log/messages-20040429 rm /var/log/messages-20040430 rm /var/log/messages-20040501 rm /var/log/messages-20040502 rm /var/log/messages-20040503 rm /var/log/messages-20040504 Now I mark the lines with the mouse and paste them into the xterm... That's enough for now.