The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 08-31-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,555
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)