[SLUG] LINUX character parsing problem.

From: Ron Youvan (ka4inm@tampabay.rr.com)
Date: Sun May 09 2010 - 18:23:54 EDT


Hi all:

   I have been having a problem with my script file that renames my digital camera files, I prepend
the date and time to every file and this works with 98% of them, but for some unknown reason an
occasional file will fail to be automatically renamed. (I never had this problem with the CP-995.)
My latest version follows: (in part)
   PreNameA=$(grep -a -A1 Ver.1.00 $FileName | cut -b 160-172 ) > /dev/null
   PreNameB=$(grep -a -A1 Ver.1.00 $FileName | cut -b 174-183 ) > /dev/null
   PreName="$PreNameA@$PreNameB"
   NewName=$PreName-$FileName
   cp -p $FileName $NewName
   mv 20*.nef ./renamed

   A line from a typical image file: (these are all Nikon *.nif files)
<
...t.2...........J.......................i.........à.%.........H...........Ì..........................NIKON
CORPORATION...NIKON D90......,.......,....Ver.1.00 ...2010:04:14 12:21:28...û\..ûÔ...........ÿ.......
>

   Immediately following the "Ver.1.00" is "2010:04:14 12:21:28" the date and time information in
the order that I wish to use, year, month and day, this causes all files to be sorted (by name) in
the order that they were exposed.

My problem is that I want to use "so many characters" after the "Ver.1.00" not "so many characters
after the beginning of the greped line," (which sometimes is different) but cut works based on "so
many character after the start of the line."

   How can I select N characters after the "Ver.1.00" in a greped line?
Thank you in advance.

-- 
    Ron  KA4INM - The next election, I know what is going to happen, I'm going to help.
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS).  Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 15:22:17 EDT