Results 1 to 8 of 8
I never used to care how files were named until I started using mostly terminal at work. Now I cannot stand it if a file name has any spaces or ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-21-2012 #1
I hate spaces
I never used to care how files were named until I started using mostly terminal at work. Now I cannot stand it if a file name has any spaces or upper case characters don't bug me as much but those spaces are going to drive me nuts. If its not to hard I might make a script to remove spaces from file names and make an alias for it so I can do it with ease.
- 12-21-2012 #2
Have a look at detox
A bit old. But still available, at least via the standard repository of a fedora 17.You must always face the curtain with a bow.
- 12-21-2012 #3
I hear and feel the hate for spaces in file names. It turns out that detox is also available in the Ubuntu repositories.
If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.
The Fifth Continent reborn
- 12-22-2012 #4
I hate spaces too and I am using detox for a long time. Works really well and save a lot time.
It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 12-22-2012 #5Just Joined!
- Join Date
- Dec 2011
- Location
- China
- Posts
- 1
yes ,you should make a script to rename your file ,and it's seem not difficult,but if you want to make a script auto rename each time ,it may be a little difficult, you can usd find . -name “*” get all your filename ,or "* *"pattern to match a file with at least one space , then there are sever ways to resolve this problem, you can choose one you like,
1.use vi to make a list of command ,copy your find command output to vi,then use command :%s///g make the string "x1 x2" to "mv x1\ x2 x1x2" copy the list of the command to shell to execute or save as a script a.sh , go out of vi ,bash a.sh
2.use shell script,
3. use c language ,C can do anything you want ,but a little difficulter than shell scripter
- 12-22-2012 #6Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,673
yeah, put me in the "hate names with spaces" camp. i've never heard of detox before, will be checking it out.
here's a couple of things i've learned, which help me nowadays.
1) when ditting around in the terminal, use a "\" character before the space in a file name (to "escape" it), then hit the [Tab] key, and bash will attempt to auto-complete the filename for you.
2) when writing scripts to deal with filenames with spaces, you'll hear about changing the IFS (Input Field Separator) bash built-in variable. don't bother with that, just use command substitution in a loop. here's an example:
Code:#!/bin/bash # script to find files in the CWD and rename them, replacing spaces w/underscores while read file; do new=$(echo $file|sed -e 's| |_|g') mv -vi "$file" $new done < <(find . -mindepth 1 -maxdepth 1 -type f -name '* *')
- 12-28-2012 #7
Never heard of detox. I have to say I love this tool and it works great.
Also available from the Sabayon repos too.
- 01-07-2013 #8
I installed detox at home and love it. I am unable to install at work so I wrote this script and it works great for replacing spaces with underscores and making every letter lower case.
It works great on a AIX system. I tried to use rename but it is not installed.Code:#!/bin/bash ls | while read -r FILE do mv "$FILE" `echo $FILE | tr ' ' '_' | tr '[A-Z]' '[a-z]' ` done


Reply With Quote
