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
  • Remote Tech Support with x11vnc and wrapper script So, the idea is that I wanted something "like" the Ultranvnc Single Click download, only for linux. The main idea being is that if someone is looking for a bit of desktop tech support on linux, we don't need to be giving instructions for 5 different package managers, or source......
  • 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......
  • Drive images - filling free space with zeros So, one of the things I've been doing is drive imaging. I've got 3 systems that are to be identical (based on, of all things Freedos...) So, I thought it was a perfect opportunity to dust off cloning/imaging software. So, I've been using the excellent g4l (ghost4linux) which is now......
Blog Traffic Exchange Related Websites
  • 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......
  • SaudiJobsNet document.write(''); Job Searching Requires a Competitive Edge Many people are looking for exciting over seas work opportunities. SaudiJobsNetwork provides listings of thousands of over seas job opportunities and the information you need to land those dream jobs. Click here for current job listings.document.write(''); Free Registration Increase your chances of......
  • 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......
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