I have a directory containing 101695 files ranging from img001.jpg to img101693.jpg and I want to move every 100th image to another directory. I have found some similar posts such as How to copy every 4th file in a folder but those assume that the number of digits in the serial is the same in all files so my range would need to start with img000001.jpg Is there a way to do this or do I need to modify my file names so that they all have the same number of characters in the serial?

  • 2
    It seems to me that Stéphane's POSIX answer there handles files of any name, as would jfg956's (and others). – Jeff Schaller Sep 9 '19 at 11:25
  • Agreed, @JeffSchaller, although it might be necessary to alter the wildcard to be img*.jpg as the accepted answer in that thread uses a five-character wildcard. – Jim L. Sep 9 '19 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.