List files by extension - several matches
Created: 2010-10-28 15:21:24
Last updated: 2010-10-28 15:22:55
The create_temporary_directory beanshell creates a temporary directory and outputs the path to that directory. The populate_directory beanshell creates several files within the temporary directory. Once the directory has been populated, it is examined by the List_files_by_extension service and the file paths to the three files ending in ".png" are output.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Titles (2)
List files by extension - several answers |
List files by extension - several matches |
Descriptions (1)
The create_temporary_directory beanshell creates a temporary directory and outputs the path to that directory.
The populate_directory beanshell creates several files within the temporary directory.
Once the directory has been populated, it is examined by the List_files_by_extension service and the file paths to the three files ending in ".png" are output. |
Dependencies (0)
Processors (4)
Name |
Type |
Description |
populate_directory |
beanshell |
Scriptcreatefile(directory, filename) {
File f = new File(directory, filename);
f.createNewFile();
}
createfile(directory, "alan.txt");
createfile(directory, "stian.txt");
createfile(directory, "jits.txt");
createfile(directory, "sergejs.bin");
createfile(directory, "carole.png");
createfile(directory, "david.png");
createfile(directory, "stuart.txt");
createfile(directory, "ian.png"); |
create_temporary_directory |
beanshell |
ScriptFile temp = File.createTempFile("taverna", ".dir");
temp.delete();
temp.mkdir();
temp.deleteOnExit();
directoryPath = temp.getCanonicalPath(); |
List_Files_By_Extension |
localworker |
Scriptclass FileExtFilter implements FileFilter {
public FileExtFilter(String ext) {
this.ext = ext;
}
public boolean accept(File file) {
return file.getName().endsWith(ext);
}
String ext = null;
}
if (extension == void || extension.equals("")) {
throw new RuntimeException(
"The 'extension' parameter cannot be null. Please enter a valid file extension.");
}
if (directory == void || directory.equals("")) {
throw new RuntimeException(
"The 'directory' parameter cannot be null. Please enter a valid file directory.");
}
File dirObj = new File(directory);
if (!dirObj.exists()) {
throw new RuntimeException("The 'directory' parameter specified:" + directory
+ "does not exist. Please enter a valid file directory.");
}
File[] fileObjList = dirObj.listFiles(new FileExtFilter(extension));
List filelist = new ArrayList();
for (int i = 0; i < fileObjList.length; i++) {
filelist.add(fileObjList[i].getAbsolutePath());
}
|
png |
stringconstant |
Value.png |
Beanshells (2)
Name |
Description |
Inputs |
Outputs |
populate_directory |
|
directory
|
|
create_temporary_directory |
|
|
directoryPath
|
Outputs (1)
Name |
Description |
matching_files |
|
Datalinks (4)
Source |
Sink |
create_temporary_directory:directoryPath |
populate_directory:directory |
png:value |
List_Files_By_Extension:extension |
create_temporary_directory:directoryPath |
List_Files_By_Extension:directory |
List_Files_By_Extension:filelist |
matching_files |
Coordinations (1)
Controller |
Target |
populate_directory |
List_Files_By_Extension |
Uploader
License
All versions of this Workflow are
licensed under:
Version 1
(of 1)
Credits (0)
(People/Groups)
None
Attributions (0)
(Workflows/Files)
None
Shared with Groups (1)
Featured In Packs (0)
None
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment