Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-11-2005, 06:20 AM   #1
Registered: Dec 2004
Location: Vienna
Posts: 46

Rep: Reputation: 15
replacing all spaces in filenames of a directory

has anyone an idea which would be the best way to replace all spaces in the all filenames of a directory?
There are many thousands of files in many directories and I want to go recursive through them...
I think maybe somehow with the find - command mixed up with some regular experssion?

Would be nice to get somenice hint

tx in regards..
Old 01-11-2005, 07:52 AM   #2
Registered: Apr 2003
Location: Bangalore,India
Distribution: FC2, RHES, RH9, FC3, FC1, Slackware 3.0
Posts: 208

Rep: Reputation: 30
$ cat /tmp/t
dst=`echo "$1" | tr ' ' '_'`
if [ "$src" != "$dst" ]; then
mv "$src" "$dst"

$ find /home/zeropash -exec /tmp/t \{\} \;

This would replace all the spaces with _
if you have tabs etc use [:space:] for tr
does this help?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
filenames with spaces antony.booth Programming 5 11-01-2005 04:49 AM
ls and filenames with spaces rose_bud4201 Programming 10 07-01-2005 08:28 AM
Spaces in filenames with mpg123 Boffy Linux - Software 3 04-26-2004 02:51 PM
filenames with spaces - explain t3___ Linux - Newbie 14 02-17-2004 06:13 PM
spaces in filenames ebone Linux - General 2 11-12-2001 11:56 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration