How to change filename on filesystem

hi,

I’m using pub.file:stringToFile to write file to my /opt/files/ directory. Is It possible to change this file name using built-in webmethods services? I want to create file with “.tmp” extension and remove this extension if file:stringToFile is done. There is an external service (not WM) configured on /opt/files/ which retrieves created files. I want to be sure that external service gets whole file data (pub.file:stringToFile is done). Or maybe pub.file:stringToFile provides me with this?

Yes you can rename file using pub.file:moveFile (you can rename the targetfile name and move it to the same dir)

HTH,
RMG

Sorry but I don’t understand
“you can rename the targetfile name and move it to the same dir”

How can I rename this file?

In te moveFile input there is only targetDirectory and fileName params.

If I understand correctly!

You need to create a file with extension .tmp (say sample.tmp) under /opt/files/. So fileName= /opt/files/sample.tmp
should be passed as the input pub.file:stringToFile with data that you want to create.

Also make sure that this fileName path should be in list of allowedWritePaths values specified in the FileAccessControl configuration file. After updating the path reload the WmPublic package. IS restart is not required.

If you want to rename the file try writing a java service.

Hi Kolo,

It’s sort of difficult to understand your question. Do you want to rename the file once after the file is created and prepared with its content if it so then you have to write some customized service to achieve that functionality as we don’t have any built-in service. Please try the options given by various members and update us which worked in your case.

Thanks,

@MR as173d

Yes, that’s my case. So I will create my own java service to do it.