Results 1 to 8 of 8
Thread: I hate spaces
Enjoy an ad free experience by logging in. Not a member yet? Register.
I hate spaces
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.
I hear and feel the hate for spaces in file names. It turns out that detox is also available in the Ubuntu repositories.Should you be sitting wondering,
Which Batman is the best,
There's only one true answer my friend,
It's Adam Bloody West!
The Fifth Continent
I hate spaces too and I am using detox for a long time. Works really well and save a lot time.
- Join Date
- Dec 2011
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
- Join Date
- May 2011
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:
#!/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 '* *')
Never heard of detox. I have to say I love this tool and it works great.
Also available from the Sabayon repos too.
The adventure of a life time.
Linux User #296285
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.
#!/bin/bash ls | while read -r FILE do mv "$FILE" `echo $FILE | tr ' ' '_' | tr '[A-Z]' '[a-z]' ` done