samedi 21 février 2015

Script to delete files that don't match certain filenames


I have a folder with 500,000 images, sorted in subfolders by year and month. I'd like to create a script that does this:


if filename does not match any of the filenames in names.log then delete the file


names.log would contain filenames, like:


image1.jpg


photo3.jpg


redcar.jpg


balloon2323.jpg


etc... it has about 10,000 names of files I want to KEEP


I have PHP and Python on the server but I'm not sure what would be best for this. I haven't done any scripting before. Could anyone be so kind as to give me a snippet of code that would achieve that and let me know how to run it? Or maybe this can be achieved with a command instead?


Thank you!



Aucun commentaire:

Enregistrer un commentaire