Code Triangle™ Custom Software Development
homeservicessupportexperimentscontactabout
Space Replace
Especially when using Linux, filenames should never have spaces in them. However many of my thousands of music files used to have spaces all over the place. So I decided to write this program. It will convert every occurrence of a character to a different character. The obvious use is to convert ' ' (space) into '_' (underscore) however you may want to use it to do the opposite, and turn underscores into spaces.

Downloads

download filname size date
1.00 source codeSpaceReplace.c4 kbJun 19, 2007
1.00 i686 linux executablesr.bz26 kbJun 19, 2007

Usage

usage: sr [-r='_'] [-s=' '] filename
Replace Character
-s=' '
  Source Character: the ' ' (space) character can be replaced with a source character of your choice. ' ' is the default source character
-r='_'
  Destination Character: the _ (underscore) character can be replaced with a character of your choice. _ is the default replaced character

Examples
sr "Various Artists"*.mp3
  renames all files that start with "Various Artists" and end with ".mp3", Various_Artists*.mp3

sr -r='Z' -s='T' bar.Test
  renames "bar.Test" "bar.Zest"

sr -s='T' -r='Z' bar.Test
  renames "bar.Test" "bar.Zest"

sr *
  renames all files (in the current directory) with spaces, to files with underscores

If you like this program please send a message.

Known Bugs
Using * does not expand to a list of files matching the regular expression in MS-DOS or Microsoft Windows. This is because the Microsoft command prompt sends the character "*" instead of expanding to a list of files. Therefore this utility will only work in the Microsoft platform by specifically naming each file you want to alter. For example "url_to_text *.mp3" will try to find the file "*.mp3" not any file that ends with ".mp3". This is not an issue when using a modern shell like csh or bash under Linux or Windows.