Shell script help
Author
Discussion

aldi

Original Poster:

9,292 posts

267 months

Tuesday 15th August 2006
quotequote all
Help me I'm a numpty:

find -iname *.bmp | xargs -l1 convert_file

Where convert_file is a script to do some conversion and general faffing about (to 000's of files in 00's of subdirs). Problem is if a file has got a space in it, convert_file ends up seeing the first half of the filename as $1, the second bit as $2 etc. etc. and throws away the spaces. Whats the best way around this? or am I going about this all the wrong way?

Cheers
Neil

Fer

7,774 posts

310 months

Tuesday 15th August 2006
quotequote all
Sorry, away from a un*x box right now, but would be tempted to do something like:

find -iname *.bmp >>/usr/tmp/fer.$$

while true
do
read $FILE || break
converfile $FILE

done </usr/tmp/fer.$$

I am a little rusty, so all this could be b**locks, but PM me and I will have a bash tomorrow when I get into work

Pigeon

18,535 posts

276 months

Tuesday 15th August 2006
quotequote all
find -iname '*.bmp' -exec convert_file "{}" ;

Fer

7,774 posts

310 months

Wednesday 16th August 2006
quotequote all
Pigeon said:
find -iname '*.bmp' -exec convert_file "{}" ;


Showoff!

I did say I was rusty!

aldi

Original Poster:

9,292 posts

267 months

Wednesday 16th August 2006
quotequote all
Thanks Pidgeon, Sorry fer there was less typing involved in his method