Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

A friend of mine took the liberty to remove all white-spaces " " in the foldernames on our shared drives and substitute them with the underline character "_" . The filenames are unaffected, and the error is systematic propagated in foldernames only

Any good proposal on which command could resolve this?

Thanks..!

share|improve this question
1  
Why do you want to put the white spaces back in? Names without white space are much easier to work with in the terminal as well as other things –  cosmorogers Dec 6 '11 at 11:39
    
Possible duplicate of askubuntu.com/questions/33626/… –  Caesium Dec 6 '11 at 12:01
    
add comment

2 Answers 2

up vote 2 down vote accepted

If you really want to go back to spaces, here is the command, only for files

find /path -type f -iname '*_*' -exec bash -c 'echo mv -i "$1" "${1//_/ }"' _ {} \;

This only shows what would do, remove the echo to really exec.

Next you can change also directory substituting -type f with -type d.

share|improve this answer
    
This worked perfectly: find -type d -iname '_' -exec bash -c 'mv -i "$1" "${1//_/ }"' _ {} \; Thank you enzotib! –  BHM Dec 6 '11 at 16:09
add comment

Use the rename tool:

$ rename "_" " " */*/ */*/*/
share|improve this answer
    
/media/gb_01/ folders already exist$ rename "" " " */*/ */*/*/ Bareword "" not allowed while "strict subs" in use at (eval 1) line 1. –  BHM Dec 6 '11 at 16:06
    
be sure to get your quotes right. –  cweiske Dec 6 '11 at 16:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.