All it does is put a file into a folder with the same base name as the file. Something I do fairly often, for example if I want to put a cover image and a description file in with some media. It's also handy because if you name something with the same base and different extensions - for example a DVD with an .srt file - it puts it into the same folder. I just tweaked it a little to give the same results as gpc, i.e. no dot when you get the extension.
You can, of course, select multiple files (and even folders?!) at once, and it puts them all into the correct folder depending on their base name.
The only reason I'm sharing it is because getting the regex right was a little tricky, and I thought others might find it useful.
Code: Select all
rename r, "^((?:(?:.+)(?=\.)(?!\.[ ]))|(?:.+))(?:\.(.+))? > $1\$1.$2", "p";
/* Captures from the beginning everything up to the last dot using a positive lookahead to skip intervening dots,
or captures everything if there is no dot, into $1. Using a negative lookahead, this skips identifying anything as an extension
that has a dot followed by a space. $2 is an optional extension.
This works fine on files or folders: $1 is the base, $2 is the extension.
*/