Skip to content

Instantly share code, notes, and snippets.

@madprops
Created October 24, 2017 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madprops/8f7124d85ecdfe75bf5ac81374621c85 to your computer and use it in GitHub Desktop.
Save madprops/8f7124d85ecdfe75bf5ac81374621c85 to your computer and use it in GitHub Desktop.
Find files that match something in the metadata information and move them to another directory. Useful if you want to move a bunch of files from some artist without descriptive filenames but correct metadata
import os
import shutil
import subprocess
path = "/some/path"
destpath = "/some/other/path"
to_match = "Maybe an Artist name"
filenames = next(os.walk(path))[2]
for fn in filenames:
meta = subprocess.getoutput("ffprobe " + path + fn)
if to_match in meta:
shutil.move(path + fn, destpath + fn)
print(fn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment