Skip to content
Advertisement

JMeter: Groovy code for moving files from one directory to another stopped working. Any better approaches?

I had used the below mentioned Groovy code in the JSR223 Sampler to move my file from one directory to another. This was working until a few days back, now it no longer does. Any suggestions on how to get it working? Also, I tried using a Beanshell sampler to perform the same task, but was not successful with that as well. Open to alternative approaches. Thanks in advance.

Groovy Code in JSR223 Sampler:

JavaScript

Java code in Beanshell Sampler:

JavaScript

Advertisement

Answer

If you want to move the file I would rather suggest using File.renameTo() function like:

JavaScript

If you’re looking for an alternative approach it could be using OS Process Sampler and invoking move command from there

Also check jmeter.log file for any suspicious entries, if Groovy script fails somewhere somehow most probably you will be able to find the reason or explanation there

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement