A chronological documentation test project, nothing serious, really!

02 Feb 2012 Recursively symlinking files

This is a short script I use to symlink all my JPG image files on my file server to a flat folder accessible to my DLNA enabled devices.
My files are organized in year folders and under each year there are month folders:


I avoid duplicate symlinks by using file names like 20110102-1234_DSC…JPG or YYYYMMDD-HHMM_OriginalFileName.JPG

The script looks like this



# Create a symlink under $DEST for each JPG file under $SRC
find $SRC -type f | grep -i jpg | while read PATHNAME; do
        echo "$NEW";
        ln -s "$PATHNAME" "$NEW";

Tags: , ,

Posted by

13 Oct 2008 Rename files in a folder to lower-case using perl

This is a simple oneliner to rename files to lower-case using perl

# perl -e 'rename($_, lc) || warn "$_: $!\n" for @ARGV' *

You can also do this recusively using find and perl

# find . -type f -exec perl -e 'rename($_, lc) || warn "$_: $!\n" for @ARGV' {} \;

Tags: , ,

Posted by

01 Nov 2007 Grep recursively through subdirectories

grep recursively through subdirectories for files that match a specific pattern:

grep -l -r –include=*.doc regex *

The equivalent command unsing find:

find . -name ‘*.doc’ -exec grep -l regex \{\} \;

The option after grep is the lowercase letter L, not the number 1).
Remove the -l to see the actual matches instead of the file names.

Tags: , ,

Posted by

09 Jun 2007 Find files not readable by all (useful for web site)

find -type f ! -perm -444


Posted by

18 May 2007 Fikse rett dato på bildefil ut i fra EXIF info

Av og til kopierer man bilder og da kan det hende bildefila får feil dato og tid for når bildet ble tatt. Kjør dette scriptet er for å rette dette igjen

Tags: , , ,

Posted by