Showing posts with label whitespace. Show all posts
Showing posts with label whitespace. Show all posts

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:
IFS=$'\n'
for filename in $(ls *.jpg)
do
 subFilename=$(echo $filename | cut -d' ' -f3)
 mv $filename [myNewPrefix]-$subFilename
done
And now I'll hopefully remember it - at least I'll be able to find it here.

Read more