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
  • Using the command line in linux - part 2 This is part two in a series of "how to use the command line in linux" style articles.... these are intended to be quite basic for those that have not used a command line before.... In part one we logged in (if necessary) and found out about the help command,......
  • 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......
  • Sleuthkit - windows and linux file recovery http://www.sleuthkit.org/ Sluethkit... is a collection of tools for forensic analysis of a system. Usually it's something that would be done when you've had a suspected rootkit on the system and you boot to another operating system with sluethkit installed (maybe livecd/etc.) and want to try to analyze and hunt for......
Blog Traffic Exchange Related Websites
  • 15 Products that save Time, Money, and Space The holidays are quickly approaching and that means shopping season is in high gear. Good luck going to a mall. It's too crowded for my taste. I'll be getting almost all of my gifts on Amazon and Ebay. For the rest, I'll pick up gift cards from the local drugstore.......
  • Release Your Disk Space And Increase Computer Speed You probably have dealt with cleaning your hard drive the hard way: one file at a time. There is nothing more annoying that doing this, especially when you are attempting to consolidate a lot of duplicate information. You could go one file at time and allow the system to add......
  • 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