Issue with PSUtilities.file:renameFile() after moving file to archive folder

Currently, after uploading the file to an SFTP host, I move the local file to an archive directory.

Program logic:

  1. PSUtilities.file:moveFile() — move file from
    D://upload/D://upload/backup/
  2. PSUtilities.file:renameFile() — rename the archive file from
    D://upload/backup/test_file.xlsxD://upload/backup/test_file.xlsx_20250812

Occasionally, PSUtilities.file:renameFile() fails with the following message:

PSUtilities.file:renameFile() – Move file and obtain target path

If I retry a few times, it sometimes works.

Question:

  • What could cause renameFile to fail right after moveFile?
  • Is it possible that the file is still locked by the OS after the move operation on Windows?
  • Any recommended best practices to avoid this issue (e.g., delay, direct move+rename in one step, etc.)?

Thank you!

webMethods tech community is moved to IBM. Check the banner on top.

Answer to your question, I am not sure why it can fail there but you can remove the second step and just rename your file and move at the same time. FTP doesn’t have a move function. It uses rename behind the scenes. Use rename service in ftp/sftp client as below.

pub.client.sftp:rename

oldPath : D://upload/test_file.xls
newPath: D://upload/backup/test_file.xlsx_20250812

it will rename and move at the same time.