Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a folder with images(png, bmp, jpg) and extension-less files.

I cant figure out how to move only the extension-less files. They are all random numbered files.

share|improve this question

With bash

shopt -s extglob
mv -- !(*.jpg|*.png|*.bmp) targetdir/
share|improve this answer
    
The ! is to tell the command to do the opposite of what is specified? – Dominique May 2 '14 at 22:28
    
@Dominique, ! is an extended glob operator that matches anything other than the patterns specified, read more about it here – iruvar May 2 '14 at 22:35
1  
Can I just suggest writing the target directory as targetdir/ to guard against the case where if it doesn't exist, the source files are successively renamed as targetdir? – steeldriver May 2 '14 at 22:44
    
@steeldriver, good point, incorporated. Feel free to edit anytime – iruvar May 2 '14 at 22:47
    
@steeldriver, if there are several sources, mv won't do anything if the target isn't a directory. But you are right in that it won't work right if there is just one source – vonbrand May 3 '14 at 8:59

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.