Saturday, October 28, 2006

Uhmm whitespaces in filenames, now what was it about the IFS....

pencil icon, that"s clickable to start editing the post

I had to rename som digital images, so startet to write a simpel for-loop in bash, but uhmmm ..... oh no I foregot that those whitespaces needs special attention. I googl'et it and found the needed help linuxquestions and of course also in The Advanced Bash-Scripting Guide

It ended something like this:
for filename in $(ls *.jpg)
 subFilename=$(echo $filename | cut -d' ' -f3)
 mv $filename [myNewPrefix]-$subFilename
And now I'll hopefully remember it - at least I'll be able to find it here.


gavenkoa said...

You can use

find . -name "*.jpg" | \
while read line; do \
...; \

pattern to make loop through files.

I wont as how you get hacks on

This page don't allow comments.
Seems that

also work!

gavenkoa said...

Seems that

<!-- <body> -->

before 'body' also work!

Sweetxml said...

Hi gavenkoa

Thank you for the BASH tip.

Regarding the other article I have no idea why comments are not possible, but my first guess is that the link somehow get hidden. I haven't looked at it for ages, but since my layout seems to be unchanged I guess they haven't changed it at all.

Happy Christmas