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:
-2011 --2011-01 --2011-02 --2011-03 ... -2012 --2012-01
I avoid duplicate symlinks by using file names like 20110102-1234_DSC…JPG or YYYYMMDD-HHMM_OriginalFileName.JPG
The script looks like this
#!/bin/bash SRC="/media/Images" DEST="/media/SymlinkTarget" # Create a symlink under $DEST for each JPG file under $SRC find $SRC -type f | grep -i jpg | while read PATHNAME; do NEW="$DEST"; echo "$NEW"; ln -s "$PATHNAME" "$NEW"; done
Posted by Hans-Henry Jakobsen
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' {} \;
Posted by Hans-Henry Jakobsen
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.
Posted by Hans-Henry Jakobsen
find -type f ! -perm -444
Tags: find
Posted by Hans-Henry Jakobsen
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
(more…)
Posted by Hans-Henry Jakobsen