Rename folder using powershell

Hi,

I have a logic that received a file from email then save (using Save Attachment activity) it to a temporary “today” folder eg. \20180531 . After scanning of data inside the file, I would rename (use Powershell) this folder to \20180531_(clientID).

The problem found is that the rename action sometimes work sometimes not work. It cannot successfully done in stable way. It seems to me that the folder is locked by someone then the powershell cannot rename this folder. Sometimes the folder is locked even the whole workflow has been completed…

If I closed the UiPath Studio, the folder is unlocked. How can I solve this problem ? I still not quite sure which part cause the rename issue.