If you have Python and is able to use it as an alternative:
Code:
#!/usr/bin/python
import os,re
for root,dir,files in os.walk("/test"):
for fi in files:
if fi.count(" ")>0:
fi=fi.strip()
newfile = os.path.join(root,re.sub("\s+","-",fi))
os.rename(os.path.join(root,fi),newfile)