How to serch files ChangeSet with the same name under separate parent folders in SCM
There are two different folders under the same Stream and the same component.
Accepted answer
The IChangeSetSearchCriteria (and IChangeSetPropertiesSearchCriteria [which it also extends]) does not support additional filtering by the parent folder of a modified file.
I would suggest if you can track down the itemID (UUID) of the file (IVersionable) you are trying to find, then instead of using searchCriteria.setName() you would instead use: searchCriteria.setItem(IVersionableHandle value).
.. and here is how you build up the item to pass in:
String fileItemIdString = "TODO"; // This is the UUID / itemId of the file
IFileItem file = (IFileItem) IFileItem.ITEM_TYPE.createItemHandle(fileItemIdString , null);
Otherwise if you don't track down the itemId (UUID) of the file you are looking for, and are instead just searching by file Name (which could match files in 'any' folder in the component), then for each IChangeSetHandle you get back, you would then need to fetch the full IChangeSets (do this in bulk though), then iterate across the changes in each change set (represented as IChange objects) (which could be changes to other files and folders) until you find the file with the name you were looking for, then you'd have to calculate the remote file path in order to determine it's the one you want (or if you had the parent folder UUID, you can just check that, which would be faster).. Note: I am saying you'd have to figure out the full remote path (up to the component root), because in your example above, you could get results in which text.txt is in "<component_root>/randomDir/randomDir/fileA/fileA.txt" (and so if you just checked the parent folder name, which would be 'fileA' in this case you may think you found the right file, but it might not be, because the expected parent folder is actually nested in some other unexpected parent folder