Converting spaces in filenames to underscores



Linux supports long file names, in some (many?) ways better than windows. However, when I moved over to linux I had tons of files with spaces in the name. This isn’t really a problem usually, but it can be a bit annoying having to enclose the filename in quotes for everything… anyway. Most of these were mp3′s that I had ripped from my collection of cd’s to store on the server. The script I used to automatically play through the music archive had problems dealing with the spaces (and I didn’t want to figure out how to make it work…) so I found another solution….


I found a bash script that basically does the job. It’s very simple and I can’t take credit for writing it, but if you want to convert spaces in filenames to underscores then this is for you…..

#!/bin/bash
for i in $(ls -1 *)
do
rename _ *.$1
done

Basically, it takes the file extension of the files you want to rename as an argument, so to rename files with spaces that are mp3s…. call it like this

$convertspaces mp3

and everything in the current directory get’s “fixed”.

Related Posts

Blog Traffic Exchange Related Posts
  • Apache2 not starting because of ssl_scache file I mentioned this a while back, but I didn't go into much detail on a long term solution. Let me re-set the situation. Linux server running apache2. It's Mandrake (now Mandriva) (an older version.) When the system has suffered abrupt outage (power loss). Everything starts up normally with the exception......
  • New office suite release Desktop Linux reported Friday that Thinkfree office has promoted their $49.95 office suite at LinuxWorld (last week.) This is Thinkfree Office 3. It's available for Windows, Mac and Linux. Supports Microsoft office file formats, has a Microsoft-Office-like interface and "critical feature compatibility". Thinkfree Office features a Word Processor, Spreadsheet and......
  • Linux Permissions Headache Yikes, what an evening..... it started innocently enough in the afternoon. I have an old Mandrake 10.0 server that I was upgrading clamav on (recent security update). While I was at it, I was reviewing the anti-spam setup to see if I could get any better success with filtering junk......
Blog Traffic Exchange Related Websites
  • A beginner's guide to a document filing system When it came to filing systems, I was a complete newbie!  I decided to do something about it and realized I didn’t even know what to look for if I had to shop  for my filing needs! If you are like me, this primer will be of great help. There......
  • File Sharing For All People People from all over the world can share files with the others. The World Wide Web offers the significant number of opportunities to benefit from and file sharing is only one of them. It is great to spend some time surfing and looking through the information you need or just......
  • Learning Basic Money Management Skills Whether economics is your idea of a great way to fight insomnia, or you just didn’t get the benefit of learning about money management early on, it is never to late to learn the basic skills of proper money management. We highly recommend taking a brief course on finance if......
www.pdf24.org    Send article as PDF   

Similar Posts


See what happened this day in history from either BBC Wikipedia
Search:
Keywords:
Amazon Logo

Comments are closed.


Switch to our mobile site