Thanks for your answer awchisholm, could you maybe post that script?
// Edit
For everyone who's interested:
// Import the MacroHandler
import com.rapidminer.MacroHandler;
// Get the Macro Handler
MacroHandler handler = operator.getProcess().getMacroHandler();
// Get the Macro with the name "path"
String macro = handler.getMacro("path");
// Tokenize the macro by the delimiter \
List tokens = macro.tokenize("\\");
// Get the last token (the folder)
String folder = tokens.get(tokens.size()-1);
// Add a new macro named folder
handler.addMacro("folder",folder);