1

I have a following directory structure (assume no two files have the same name):

  • Apple1
    • apple1.jpg
    • apple2.jpg
  • Apple2
    • apple3.jpg
    • apple4.jpg
  • Apple3
  • Tomato
  • Peach

And i would like to move one directory to the top directory all the *.jpg files inside the directories, which names start from Apple.

As a result I expect the Apple directories to be empty and the images from Apple directories to be in the top.

I have tried doing like mv "Apple*/*.jpg" ., or find . "Apple*/*.jpg" -exec mv -t . {} + as prescribed here How to integrate mv command after find command?. But this doesn't work.

When executing mv i receive a following message:

mv: cannot stat ‘Apple*/*.jpg’: No such file or directory

Seems like it has not found anything matching the pattern. And other option simply outputs nothing. Maybe the reason is, that in the case of subdirectories regular expression needs to be modified?

I would be very grateful for help and suggestions.

Quasímodo
  • 18,865
  • 4
  • 36
  • 73

0 Answers0