I want to cut up the path to the file. {folder} gives me the string, but trying to do something like folder.before... or folder.replaceAll just gives an error, something about "No signature of method..." If I instead try the same replacement on e.g. fn, it works fine.
So what is it about the 'folder' values that causes it to fail? Should this not work? If not, why not? Seems like a perfectly valid format to me.
folder failure
Re: folder failure
{folder} gives you a File object, not a String object. It's the same as {file.parentFile}.
Use {folder.name} or {folder.path} to get a String for the folder name/path. Once you have a String you can use all the String methods on that object.
Use {folder.name} or {folder.path} to get a String for the folder name/path. Once you have a String you can use all the String methods on that object.
Re: folder failure
Ok, understood. Thanks.
Any way to easily get the folder of the folder? IOW the parent of the parent?
Also, am I right that replaceAll() can only take a string as the replacement? Is there any way to replace some text with a calculated value, like from a ternary conditional?
Any way to easily get the folder of the folder? IOW the parent of the parent?
Also, am I right that replaceAll() can only take a string as the replacement? Is there any way to replace some text with a calculated value, like from a ternary conditional?
Re: folder failure
Parent Parent Path:
Parent Parent Name:
Arbitrary Path Section:
Arbitrary Replacement Logic:
Code: Select all
{folder.parent}
Code: Select all
{folder.parentFile.name}
Code: Select all
{file[-3..-2].path}
Code: Select all
{'1 2 3'.replaceAll(/\d/){ it.toInteger() * 3 }}