[CLUE-Tech] removing spaces from filenames?

Warren Raquel clue at sohonetworksetup.com
Mon Nov 18 10:04:30 MST 2002


Here's a short shell script that you can run inside the directory to take 
care of all spaces. It should convert all files and directory names with 
spaces.

 >8-----cut here------>8
#!/bin/sh
for i in *
   do NEW=`echo $i| sed 's/ /_/g'`
   if [ "$i" != "${NEW}" ]
   then
     mv "$i" "${NEW}"
     echo "$i converted to ${NEW}"
   else
     echo 'The name is the same'
   fi
done
 >8-----cut here------>8

At 01:14 PM 11/17/2002 -0700, you wrote:
>Hi,
>
>I have a _bunch_ of files that were created on a windoze system with
>embedded spaces in their names.  Can anyone recommend a technique to
>programmatically rename the files - replacing ' ' with '_' on both the
>file and dir names?
>
>I am thinking perl, but I am not sure what sysntax I would need to use
>to search and rename.
>
>TIA
>
>aloha,
>dave
>
>_______________________________________________
>CLUE-Tech mailing list
>CLUE-Tech at clue.denver.co.us
>http://clue.denver.co.us/mailman/listinfo/clue-tech




More information about the clue-tech mailing list