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,......
  • 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......
  • 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
  • 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......
  • FREE Amazon S3 Manager FREE Manage Amazon S3 with CloudBerry S3 Explorer Stream Your Cloud After a small rant about how S3 can be a pain to mange, my buddy Andy from CloudBerry offered up a nifty solution, a FREE manager that makes working with S3 easier than FTP. CloudBerry Explorer is a familiar......
  • How do RSS Feeds Work? If you’re confounded by that little orange graphic you see on blogs, it’s time to learn all about RSS and how it can benefit your own blog. Most software packages and content management systems offer RSS capablility, but it’s up to you to implement it. When used properly, RSS feeds......
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