I have a directory with several thousand files. Many of them are images where the filename begins with the image's resolution. The height and width of the images can be two, three, four or five digits long. For example:
- 986x1088_lalbslj.jpg - 2043x924_fjnndkk.jpg - 9560x12643_fjknfd.jpg - 24x24_dnjkan.jpg
I'd like to collect all these images in a new directory (say
./images/). Sounds simple enough.
The simple regex
[0-9]+x[0-9]+.* matches these filenames, but as far as I've understood, you can't use regex with
Ideally, I'd like something like this to work:
mv [0-9]+x[0-9]+.* images, but of course, it doesn't.
It seems this questions has been asked a lot before, and I've already looked at several dozen (literally!) similar threads on this and other StackExchanges, but sadly I haven't yet seen an answer that helps me. Most of the time, the accepted answers are simply explaining that
mv uses globs and not regex, or suggesting a corresponding glob that helps the author, but which doesn't work in my case. So I'm trying my luck by asking my own question – I hope that's OK.
I can't seem to condense my pattern into any reasonable glob, and regex doesn't work with
mv, so what do I do?
Surely this must be possible somehow?!
Thank you very much for all your kind replies!