-   Linux - General (
-   -   replacing space in filenames (

rooster13 07-17-2003 06:57 PM

replacing space in filenames
is there any way to replace spaces in filenames with, for example, '_'?? I have a whole bunch of files that origin from the windows world, and my bash scripts aren't working well with the "space" characters in filenames. Thanks for your time.

linuxlah 07-17-2003 07:17 PM

try this bash script

PHP Code:

for i in *; do mv "$i`echo $i | tr ' ' '_'`; done 

rooster13 07-18-2003 04:35 AM

So, since I'm such a rookie with these bash scripts, I have to ask if this script would do the work (replace all spaces in directory and file names with '_' in all subdirs of the directory it runned from)


DIRS=$(find . -type d)
for d in $DIRS; do
cd $d
for i in *; do mv "$i" `echo $i | tr ' ' '_'`; done

All times are GMT -5. The time now is 05:35 AM.