Process files in loop which have spaces in name

I have a folder with files and I have to process them in a loop. However the filenames have space characters, so the list get split.

$ touch "File Number_1"
$ touch "File Number_2"
$ ls "/tmp/File Number"_*
/tmp/File Number_1  /tmp/File Number_2

I tried following (sorry for using the `tcsh`):

$ foreach file ( `ls "/tmp/File Number"_*` )
foreach? echo ">"$file"<"
foreach? end
>/tmp/File<
>Number_1<
>/tmp/File<
>Number_2<


$ set FILES = ( `ls "/tmp/File Number"_*` )
$ while ( $#FILES )
while? echo ">"$FILES[1]"<"
while? shift FILES
while? end
>/tmp/File<
>Number_1<
>/tmp/File<
>Number_2<

set FILES = "/tmp/File Number"_*
... same as above

Can you help me to solve my problem?

btw, I don't mind to get a solution which renames the files. The files will be renamed anyway.

Best Regards
Wernfried

Hello Wernfried,

Could you please try following and let me know if this helps(I haven't tested though.).

for file in $(find -type f -iname "File Number_*")
do
      do echo $file
done

Thanks,
R. Singh

Same result:

./File
Number_2
./File
Number_1

Best Regards

---------- Post updated at 11:25 ---------- Previous update was at 10:40 ----------

I found a working solution:

for f in /tmp/File\ Number_*; do mv "$f" "${f// /}"; done

Best Regards

Yes, quoting is the solution. Examples with " "

/tmp/File" "Number_*
"/tmp/File Number_"*
/tmp/"File Number_"*