Removing Attached Files via API

Good morning everyone.
I ask you how to remove a file attached to a WI via api.
I'll start by saying that I saw the remove method, to which you pass an iRef, but this iRef needs a path to exist that I don't have or rather, I wouldn't have, to attach it I will have the path and I have already "solved" while for the removal I might no longer have that file in the path, since it was previously removed, so how can I delete the attachment, knowing only its name?
I hope I don't have to download it and then remove it, because I also thought about this but it's not a very clean thing, at least I think.
Thank you very much everyone.
One answer

Good evening, this time I'll answer myself.
Basically by retrieving all the attachments via:
List<IReference> referenceList = workingCopy.getReferences().getReferences(WorkItemEndPoints.ATTACHMENT);
You get the list of all the attachments, for these you just need to use the get.Comment() and it contains, also the name and the extension of the same. So then you just need to do the remove if the comment contains the name.
Thank you very much everyone.