LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-13-2005, 01:01 PM   #1
Alex_jacobson
Member
 
Registered: Jul 2003
Distribution: Slackware 10.1 on 2.4.29
Posts: 55

Rep: Reputation: 15
Is it possible to remove spaces


Is it possible to remove spaces in filenames in a recursive way using a script ?
 
Old 01-13-2005, 01:22 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
You could use:
for file in `find ./ -type f`;do mv $file `echo $file|sed "s/ //"`;done
 
Old 01-13-2005, 01:52 PM   #3
Alex_jacobson
Member
 
Registered: Jul 2003
Distribution: Slackware 10.1 on 2.4.29
Posts: 55

Original Poster
Rep: Reputation: 15
Hrrm thanks, but it doesn't seem to work. Can you explain each part of your message ?
 
Old 01-13-2005, 03:48 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 60
It's just a little loop to go through all file names and replace any spaces with nothing.
IMHO, that would make the filenames pretty hard to read. You might be better off replacing all spaces with underscores. Those are back ticks ( ` ) and not single quotes ( ' )
Like this.....
Code:
for i in * ; do j=`echo $i | sed -e "s/ /_/g"`; mv "$i" "$j"; done
 
Old 01-16-2005, 10:45 AM   #5
Alex_jacobson
Member
 
Registered: Jul 2003
Distribution: Slackware 10.1 on 2.4.29
Posts: 55

Original Poster
Rep: Reputation: 15
Thanks, it works really well !
 
  


Reply


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script to remove spaces from multiple filenames jeffreybluml Linux - Newbie 36 07-31-2013 02:10 AM
Bash script to remove capitalisation and spaces form a filename scuzzman Programming 11 05-18-2008 12:28 PM
Remove white spaces in HTML files using shell : Possible???????? cpanelskindepot Programming 2 08-05-2004 11:14 PM
Need to remove spaces from all file / dir names ?? Solution here! jsjohnst Linux - General 2 07-20-2004 09:39 PM
Way to many spaces LuderForChrist Linux - Newbie 4 06-25-2004 02:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:51 AM.

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