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.

How can I rename oddly named directories without typing their full names?

I've got 8 folders with very long foldernames and I only got these folders in this path /home/user/Downloads/ - Is there any command to get every {*.txt} file from all folders and move them to another directory?

share|improve this question
    
This question is very hard to make sense of. Edit your question to tell us what you have. Then tell us what you want. We may be able to answer that question. –  msw Apr 13 '11 at 11:22
    
see - I got 8 folders with very long foldernames and I only got these folders in this path /home/user/Downloads/ - I wanted to ask if there is any command to get every txt file of ALL folders and move them to another directory ?! –  user14166 Apr 13 '11 at 11:35

3 Answers 3

If I rewrote your question properly based on your comment then

find /home/user/Downloads -type f -name \*.txt -print0 | \
  xargs -0  -I '{}' mv '{}' nice-directory

will reliably do what you ask.

share|improve this answer

To rename a directory like horrible *[name]* with$weird <characters> \\in it" you can use wildcards, for example, if you have only one directory withweird` in the name

mv "*weird*" a-regular-named-directory

where the {"} are important. Failing that you can use

ls --hide-control-chars

which will give you a listing with odd characters replaced by ? which is then a shell pattern which you can then mv.

share|improve this answer

You could just:

mv firstCoupleLetters[tab] newDir[enter] 

and rely on autocomplete to fill out the original directory name, renaming it to something shorter/more useful.

share|improve this answer

Your Answer

 
discard

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