Script to find missing file pairs
Posted: 20 Dec 2015 20:31
I don't often need a script, but when I do...I come here
I am after a script that would loop through all files in a given location (including child and grandchild folders) and pick out files that have at least one match from a given list of strings. For all such matches, I want it to show me a list of only those -- just base names will do -- which do not have a corresponding file of a specific file type. For example, for any file that has "dog" in its file name (such as "this is is my dog.jpg), I only want to see those files which do not have a corresponding text file (for that JPEG, it would be exactly "this is my dog.txt").
My flow for how such a script would work is this:
1. Get a list of all file names from the given location (assume current, unless specified otherwise) and save in a variable.
2. Loop through the complete list and search for matches of specific words. For every match, store that name in another variable.
3. Loop through the refined list and find if the corresponding file type exists. If it does not, store that name in the 3rd variable.
4. Show the final list derived from what is created in the 3rd variable.
Is there any better way to do this? If it is a piece of cake, can anyone provide skeleton code for me to tweak? Thank you in advance
I am after a script that would loop through all files in a given location (including child and grandchild folders) and pick out files that have at least one match from a given list of strings. For all such matches, I want it to show me a list of only those -- just base names will do -- which do not have a corresponding file of a specific file type. For example, for any file that has "dog" in its file name (such as "this is is my dog.jpg), I only want to see those files which do not have a corresponding text file (for that JPEG, it would be exactly "this is my dog.txt").
My flow for how such a script would work is this:
1. Get a list of all file names from the given location (assume current, unless specified otherwise) and save in a variable.
2. Loop through the complete list and search for matches of specific words. For every match, store that name in another variable.
3. Loop through the refined list and find if the corresponding file type exists. If it does not, store that name in the 3rd variable.
4. Show the final list derived from what is created in the 3rd variable.
Is there any better way to do this? If it is a piece of cake, can anyone provide skeleton code for me to tweak? Thank you in advance