title: Moving files based on numbers in filename - python
body: <p>I have hundreds of image files in a folder named in the style "imagefile_xxxx.fit" where xxxx is a number, and corresponding data files, one for every image, in the style "datafile_xxxx.cat".</p>
  
  <p>I've written a python programme that loops through all my data files and moves bad data to a directory of undesirables based on how many lines of data, and I want to then move the corresponding image file out of its directory to a folder of bad images, based on the number in the filenames.</p>
  
  <p>So if datafile_0012.cat has been moved to the directory bad_data, move imagefile_0012.fit to the directory bad_images.</p>
  
  <p>I am considering doing it the other way (copy good data to a directory and leave good and bad files mixed together in the original directory), but I still have the problem of copying image files based on the number in the data file name.</p>