| Member with 8 posts. THREAD STARTER | | Join Date: Jul 2012 Experience: Advanced | |
Need to write a batch file that compares folder names and deletes one. I have hundreds of folder names xxxx.co and xxxx.cojt. These files come in as *.co and we use a program to convert some of them to *.cojt. I have all of my files located on a E:\ drive. These are FOLDERS and not files. It's almost like a folder has an extension, but not really. Just a naming convention.
The Folders have a name before the .co and after conversion, they have the same name but now .cojt at the end of the folder name. I need to search my E:\ drive and find all FOLDERS that have the same name before the .co and .cojt. Some *.co will not have a .cojt as they are not all converted. The ones that do have a match, however, I need this batch file to delete the original xxxx.co and leave the xxxx.cojt. So basically comparing folder names before the period, and anything that matches with .co and .cojt, the .co folder gets deleted.
Thanks for the help.
Folder example:
abc123.co
abc123.cojt
123abc.co
1234.cojt
microsoft.co
microsoft.cojt
So if i had these 6 folders, the ones to be deleted would be abc123.co and microsoft.co as they have an identical .cojt folder.
One other twist in this is that some of these may be all over the E:\ drive in different subfolders. For example.
E:\folder1\abc123.co
E:\folder2\abc123.cojt
The first one, E:\folder1\abc123.co still needs to be deleted because they are the same just in different sub-directories.
Thanks for the help. |