List files from folder and subfolders recursively in JMeter
up vote
0
down vote
favorite
I use BeanShell Sampler in JMeter to list all the files from a folder. It lists files only from directory and unable to do the same in subdirectories
File folder = new File("C:\_private\Files\input");
File files = folder.listFiles(new FileFilter() {
public boolean accept(File file) {
return file.isFile();
}
});
for (int i=0; i < files.length; i++) {
vars.put("file_" + i, files[i].getAbsolutePath());
}
java groovy jmeter beanshell
add a comment |
up vote
0
down vote
favorite
I use BeanShell Sampler in JMeter to list all the files from a folder. It lists files only from directory and unable to do the same in subdirectories
File folder = new File("C:\_private\Files\input");
File files = folder.listFiles(new FileFilter() {
public boolean accept(File file) {
return file.isFile();
}
});
for (int i=0; i < files.length; i++) {
vars.put("file_" + i, files[i].getAbsolutePath());
}
java groovy jmeter beanshell
1
Possible duplicate of List all files from a directory recursively with Java
– Deepak Gunasekaran
Nov 7 at 10:10
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I use BeanShell Sampler in JMeter to list all the files from a folder. It lists files only from directory and unable to do the same in subdirectories
File folder = new File("C:\_private\Files\input");
File files = folder.listFiles(new FileFilter() {
public boolean accept(File file) {
return file.isFile();
}
});
for (int i=0; i < files.length; i++) {
vars.put("file_" + i, files[i].getAbsolutePath());
}
java groovy jmeter beanshell
I use BeanShell Sampler in JMeter to list all the files from a folder. It lists files only from directory and unable to do the same in subdirectories
File folder = new File("C:\_private\Files\input");
File files = folder.listFiles(new FileFilter() {
public boolean accept(File file) {
return file.isFile();
}
});
for (int i=0; i < files.length; i++) {
vars.put("file_" + i, files[i].getAbsolutePath());
}
java groovy jmeter beanshell
java groovy jmeter beanshell
edited Nov 7 at 11:24
user7294900
17.9k93056
17.9k93056
asked Nov 7 at 10:01
plaidshirt
56132467
56132467
1
Possible duplicate of List all files from a directory recursively with Java
– Deepak Gunasekaran
Nov 7 at 10:10
add a comment |
1
Possible duplicate of List all files from a directory recursively with Java
– Deepak Gunasekaran
Nov 7 at 10:10
1
1
Possible duplicate of List all files from a directory recursively with Java
– Deepak Gunasekaran
Nov 7 at 10:10
Possible duplicate of List all files from a directory recursively with Java
– Deepak Gunasekaran
Nov 7 at 10:10
add a comment |
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
Move to use JSR223 Sampler with the following code using FileUtils:
import org.apache.commons.io.FileUtils;
List<File> files = FileUtils.listFiles(new File("C:\_private\Files\input"), null, true);
Notice to replace files.length with files.size():
for (int i=0; i < files.size(); i++) {
vars.put("file_" + i, files[i].getAbsolutePath());
}
add a comment |
up vote
1
down vote
You'll need to do it recursively. You can list all the directories the same way you did for the files, and then call the function you created, recursively. When you then call the function with your initial file, it will traverse the tree structure and give you all files in a list. To add to a list use addAll.
def listFiles(File folder) {
... // Recursive function
}
add a comment |
up vote
1
down vote
Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for any form of scripting mainly because Groovy performance is much better comparing to other scripting options
Groovy in its turn provides File.eachFileRecurse() function which is exactly what you're looking for.
Example code:
def index = 1
new File('c:/apps/jmeter/bin').eachFileRecurse(groovy.io.FileType.FILES) {
vars.put('file_' + index, it.getAbsolutePath())
index++
}
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Move to use JSR223 Sampler with the following code using FileUtils:
import org.apache.commons.io.FileUtils;
List<File> files = FileUtils.listFiles(new File("C:\_private\Files\input"), null, true);
Notice to replace files.length with files.size():
for (int i=0; i < files.size(); i++) {
vars.put("file_" + i, files[i].getAbsolutePath());
}
add a comment |
up vote
1
down vote
accepted
Move to use JSR223 Sampler with the following code using FileUtils:
import org.apache.commons.io.FileUtils;
List<File> files = FileUtils.listFiles(new File("C:\_private\Files\input"), null, true);
Notice to replace files.length with files.size():
for (int i=0; i < files.size(); i++) {
vars.put("file_" + i, files[i].getAbsolutePath());
}
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Move to use JSR223 Sampler with the following code using FileUtils:
import org.apache.commons.io.FileUtils;
List<File> files = FileUtils.listFiles(new File("C:\_private\Files\input"), null, true);
Notice to replace files.length with files.size():
for (int i=0; i < files.size(); i++) {
vars.put("file_" + i, files[i].getAbsolutePath());
}
Move to use JSR223 Sampler with the following code using FileUtils:
import org.apache.commons.io.FileUtils;
List<File> files = FileUtils.listFiles(new File("C:\_private\Files\input"), null, true);
Notice to replace files.length with files.size():
for (int i=0; i < files.size(); i++) {
vars.put("file_" + i, files[i].getAbsolutePath());
}
answered Nov 7 at 10:20
user7294900
17.9k93056
17.9k93056
add a comment |
add a comment |
up vote
1
down vote
You'll need to do it recursively. You can list all the directories the same way you did for the files, and then call the function you created, recursively. When you then call the function with your initial file, it will traverse the tree structure and give you all files in a list. To add to a list use addAll.
def listFiles(File folder) {
... // Recursive function
}
add a comment |
up vote
1
down vote
You'll need to do it recursively. You can list all the directories the same way you did for the files, and then call the function you created, recursively. When you then call the function with your initial file, it will traverse the tree structure and give you all files in a list. To add to a list use addAll.
def listFiles(File folder) {
... // Recursive function
}
add a comment |
up vote
1
down vote
up vote
1
down vote
You'll need to do it recursively. You can list all the directories the same way you did for the files, and then call the function you created, recursively. When you then call the function with your initial file, it will traverse the tree structure and give you all files in a list. To add to a list use addAll.
def listFiles(File folder) {
... // Recursive function
}
You'll need to do it recursively. You can list all the directories the same way you did for the files, and then call the function you created, recursively. When you then call the function with your initial file, it will traverse the tree structure and give you all files in a list. To add to a list use addAll.
def listFiles(File folder) {
... // Recursive function
}
answered Nov 7 at 10:14
SBylemans
873417
873417
add a comment |
add a comment |
up vote
1
down vote
Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for any form of scripting mainly because Groovy performance is much better comparing to other scripting options
Groovy in its turn provides File.eachFileRecurse() function which is exactly what you're looking for.
Example code:
def index = 1
new File('c:/apps/jmeter/bin').eachFileRecurse(groovy.io.FileType.FILES) {
vars.put('file_' + index, it.getAbsolutePath())
index++
}
add a comment |
up vote
1
down vote
Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for any form of scripting mainly because Groovy performance is much better comparing to other scripting options
Groovy in its turn provides File.eachFileRecurse() function which is exactly what you're looking for.
Example code:
def index = 1
new File('c:/apps/jmeter/bin').eachFileRecurse(groovy.io.FileType.FILES) {
vars.put('file_' + index, it.getAbsolutePath())
index++
}
add a comment |
up vote
1
down vote
up vote
1
down vote
Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for any form of scripting mainly because Groovy performance is much better comparing to other scripting options
Groovy in its turn provides File.eachFileRecurse() function which is exactly what you're looking for.
Example code:
def index = 1
new File('c:/apps/jmeter/bin').eachFileRecurse(groovy.io.FileType.FILES) {
vars.put('file_' + index, it.getAbsolutePath())
index++
}
Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for any form of scripting mainly because Groovy performance is much better comparing to other scripting options
Groovy in its turn provides File.eachFileRecurse() function which is exactly what you're looking for.
Example code:
def index = 1
new File('c:/apps/jmeter/bin').eachFileRecurse(groovy.io.FileType.FILES) {
vars.put('file_' + index, it.getAbsolutePath())
index++
}
answered Nov 7 at 13:09
Dmitri T
66.2k33256
66.2k33256
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53187185%2flist-files-from-folder-and-subfolders-recursively-in-jmeter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Possible duplicate of List all files from a directory recursively with Java
– Deepak Gunasekaran
Nov 7 at 10:10