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
  • 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......
  • chkconfig for ubuntu or other debian based linux systems As I've mentioned I've got an ubuntu based test system. Most of my linux experience has been from a red-hat derivitive-based background and for that, at the command line, you have chkconfig which is a good tool for checking the configuration of services to run at startup. It is a......
  • 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......
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.......
  • The Nickname Cache in Outlook - Get to Know your .NK2 file Have you ever wondered where Outlook stores data it uses to auto-complete email addresses when you are typing in the To or Cc field?  Microsoft stores this data in a file with the extension .NK2.  The file is stored in each user's profile in drive:\Documents and Settings\user name\Application Data\Microsoft\Outlook.  Note......
  • 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......
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