Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

1 Answer 1

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 at 22:28
    
@Dominique, ! is an extended glob operator that matches anything other than the patterns specified, read more about it here –  1_CR May 2 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 at 22:44
    
@steeldriver, good point, incorporated. Feel free to edit anytime –  1_CR May 2 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 at 8:59
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.