So it happens that something easy and fast with a filemanager becomes a little bit harder. But still the command line, with all GNU tools around and interpreters of languages like perl, is powerful.
When I download pictures from the cam, I need renaming them according to EXIF date; so I've created a script (exifrename.sh), which uses exif the extract the date and rename the object the way I want. I use it like this
exifrename.sh *.jpg |bash
The pipe is because the script outputs the commands rather than executing them (it could be useful to check everything's fine).
My cam creates a directory for each day, like NUMcanon where NUM is a number not related to the day. What I want is to copy just some days, not all, into the local hard disk and in the same time I want to strip the "canon" part. It would be easier maybe to copy the dirs and then rename them. But less fun for me. So what I do is
for el in 101 102 105 ; do mkdir $el ;
pushd $el ;
cp -r /media/usbpen/dcim/${el}canon/* . ;
popd ; done
Ok not so funny but useful to... Recently I had to convert several scattered .doc (alas Microsoft stuff) into HTML, I've used this
find . -iname "*.doc" |
(
while read line;
do wvHtml "$line" "${line%.doc}.html ; done
)
As last example, a "oneliner" to read FASTA headers / sequences and sort them (just the header). Don't ask why, I've found the request on Yahoo Answer.
perl -e '%p=();
while(<>) {
if (/^>/) {
s/^>//; chomp;
foreach $v (split("\x01", $_)) {
$p{$v} = 1 if !exists $p{$v} ;
}
}
}
print join(" ", sort keys %p)' <fasta.txt
A perl guru can make surely better (and what about perl6?), anyway the solution worked .
Now we discover that there are things that can't be done simply by a graphics interface but... These examples are taken directly from the history of the shell; there are other two similar examples. The history has 1045 entries. Of these, 1039 are mainly simple commands like cd, rm, cp, ls, mkdir (and sometimes mount and umount). Actions that would have been a lot easier using a graphical file manager!
So the problem said at the beginning is back: I need keeping running few processes/programs. ... I'm going to hate the computer business, because I can't see a reason why to do the same thing I did before now I need more memory or a more powerful processor... or downgrading the software (meaning I should compile by myself a lot of codes since oldest packaged pre-compiled programs are already too recent, or there are too many dependencies issues I don't want to cope with!)
I hope things will be better, but looking around I see things indeed get worse: we can say Berlusconi is the winner, and this means there's no hope to change for Italy (it seems OT, but is not...).
Ah, the exifrename.sh code:
for el in "$@"; do
pathpart=$( dirname "$el" )
namepart=$( basename "$el" )
data=$( exif "$el" |egrep "Date and Time \(orig" \
|sed -e 's/^.*|\([0-9]\{4\}\):\([0-9][0-9]\):\([0-9][0-9]\) \([0-9][0-9]\):\([0-9][0-9]\):.*$/\1\2\3-\4\5/' )
echo "mv \"$el\" \"$pathpart/$data-$namepart\""
done