I have multiple screenshots since 2008 with name like "screenshot-2010-13-12.jpg". I need to copy screenshots since 2010 to 2019. I tried different options with -name and -regex , but cant find the way. The only success with regex is finding by format, nothing more.

  • 2
    cp screenshot-201* whereever Dec 9, 2021 at 7:16
  • @ThorstenStaerk, this will find also screenshot-201aaa.doc Dec 9, 2021 at 7:21
  • find -iname "screenshot-201[0123]" will show you all files named screenshot-2010 screenshot-2011 till screenshot-2013. You can refine this search to adhere to your exact format. Where are you struggling? Dec 9, 2021 at 7:24
  • @ThorstenStaerk, this will find also Screenshot...., screenshot-2013, but not screenshot-2019-13-12.jpg. And will show also the directories. Dec 9, 2021 at 7:26
  • @RomeoNinov what directories? Dec 9, 2021 at 8:23

2 Answers 2


If you want to be strict about the format something like this can do the work:

find . -name "screenshot-201[0-9]-??-??.jpg" -type f

This will search for files whose name starts with screenshot-201, then has a digit, then dash, two characters, dash, two characters and .jpg


To generalise to arbitrary range of dates, in zsh you could do:

cp screenshot-????-??-??.jpg(.e['
  [[ $REPLY >= screenshot-2010-02-12.jpg &&
     $REPLY <= screenshot-2019-09-21.jpg ]]']) /some/dir/


cp screenshot-????-??-??.jpg(.e['
  [[ ${REPLY//[^0-9]} = <20100212-20190921> ]]']) /some/dir/

To copy regular (with .) files in the 2010-02-12 to 2019-09-21 range for instance.

If they're not in the current working directory but you need to search for them in any level of subdirectories:

cp -i -- **/screenshot-????-??-??.jpg(.e['
  [[ $REPLY:t >= screenshot-2010-02-12.jpg &&
     $REPLY:t <= screenshot-2019-09-21.jpg ]]']) /some/dir/

(here adding -i to mitigate the risk in case several files with the same name are found in directories).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .