Custom Script to Get File Name from Path

Here’s a simple script that I used to grab the name of files. This might be handy if you just need the name of the file without the extension, given a string path. I recently discovered a useful
library that can do so much more than just this!

import org.apache.commons.io.FilenameUtils

 @CustomScriptAction(
     input = ['input_str'],
     outout = 'output_str'
 )

 def getFileNameFromPath() {
     output_str = RString.of(FilenameUtils.getBaseName(input_str.toString()))
 }
5 Likes