Re: Backing up suggestions?



On Mon, 21 Aug 2006, houghi <houghi@xxxxxxxxxxxxxxxxxx> wrote:-

David Bolt wrote:

<Snip>

$! returns the PID for the most recently started background process.

OK. I knew that, I just was unable to find it. :-0

man bash? :-)

That's a good idea for only a few pictures, but it would become awfully
repetitive when doing a batch rename with several images of the same
subject. And since I often have 50-100, or even more, images to rename,
it would get annoying very quickly.

I asume uou use the same sort of nameing each and every time.

Similar. All the pictures taken by my cameras are named to identify
which camera, the picture number the camera assigns the image, and a
(very) short description of the subject. The name ends up being changed
from XXXXNNNN.EXT to fNNNN_SUBJECT.ext.

That can
easily be put in the script for those 50 or 100. Something that will
first ask what the generic name will be, then with the second picture,
if you just press enter, you will use that and add it to the name.

That's almost what the script does. It looks for picture names starting
with the four characters, replaces those with the identifier flag letter
and then appends the "name" I choose. That way I get to keep the
pictures in sequence and, using find, can also locate those with a
particular name.

I personally even put all things in lowercase and add a _ instead of a
space.

Almost the same here. I will use mixed case, use _ instead of a space,
and also change any '&' in a filename to '+'

I suppose that could be a choice. I'd still need an option to disable
the GUI or, more likely, one that needs to be set to enable it.

Not that difficult to build in. The question is if it is worth it.

In my case, no. I can be a stubborn old fool who's stuck in his ways.

You remember the "if it isn't broke..." quote? Well, this time I did
change it slightly, even though it isn't broke. Those four lines are now
a single one:

Yes, I did not mean to change it. I just said how I would do it.

It does the exact same job, it's three lines shorter, it's only executed
once making it's faster, so there was no reason to not change it.

# namepics.sh
#
# renames pics from *_NNNN.jpg to NNNN_*.jpg

That should really read

# renames *_NNNN.$EXT to xNNNN_$NAME.$EXT

<snip>
mv "$i" "$j"

What about mmv?
mmv "*_*.jpg" "#2_#1.jpg"

That would have worked before I bought my second digital camera and had
to alter how the names were made up. It would also fail now because my
Nikon doesn't include a '_' in the file names.

At this moment I am reorganizing my wallpapers. All 25.000 or so of
them. As I plan on doing this only once and because the naming is so
Fucked Up, I wil first be doing a sorting by filename.

Good luck to you. If you aren't seen for a few days should we send out a
search and rescue party?

Looking at the actuall pictures will be for a much later state. Just
spend about two hours on the letter A. :-)

I'm so glad I picked a decent naming format for my pictures before I
ended up with the number of pictures I have. I certainly don't envy you
having to go through all the

After I have sorted the majority (Say 95%) I will rename the files in
each directory to something like $DIRECTORY_date_NNNN where $DIRECTORY is a
first and second name, like ashley_judd_20060921_1234.jpg. This will also
mean that wallpapers from Lisa Marie Scott will be
lisa_marie_20060921_1234.jpg.

This should work but, just in case, it doesn't actually do anything

# rename files using the directory name, date and a counter
#
COUNTER="0"

# Just for degugging purposes. If all seems well, replace with either "cp" or "mv"
#
MV="echo 'mv' "

for FILE in $(find -type f -name "*.jpg"|sort)
do

# create a filename taken from the date and directory name
#
while :
do

NEW_NAME=$(printf "%s_%s_%04u" $(basename $(dirname $(echo "$FILE"|sed -e "s# #_#g"))) "$(date +%Y%m%d)" "$COUNTER")

# make sure there isn't already a file with the new name
#
[ ! -e "$(dirname $FILE)/$NEW_NAME" ] && break

# increment the counter
#
COUNTER=$(($COUNTER+1))
done

$MV "$FILE" "$(dirname $FILE)/$NEW_NAME"

done

Of course, you could easily modify the script so the counter is reset
every time it enters a new directory, instead of the continual increment
it presently has.

People with only one name will get a second one from me.

Something like nsn (no second name)?

I have to take some shortcuts. :-/

That's what scripts are there for.


Regards,
David Bolt

--
Member of Team Acorn checking nodes at 50 Mnodes/s: http://www.distributed.net/
AMD1800 1Gb WinXP/SUSE 9.3 | AMD2400 256Mb SuSE 9.0 | A3010 4Mb RISCOS 3.11
AMD2400(32) 768Mb SUSE 10.0 | Falcon 14Mb TOS 4.02 | A4000 4Mb RISCOS 3.11
AMD2600(64) 512Mb SUSE 10.0 | | RPC600 129Mb RISCOS 3.6
.


Loading