Multi Commander > Script

MultiScript Name selection excluding file extension?

(1/6) > >>

Ulfhednar:
I'm wondering about how to exclude the file extension with multiscript.  (Obviously MultiRename has a switch for this.)

If I use GetSourceSelectedFileNames or similar, I get a complete name.
I thought about generating a list of files to clipboard without extensions & I thought about renaming using a regex but excluding the extension.

Whilst I can imagine using something like (pdf$|txt$) in the regex to force to an end of name, this is quite restrictive.
It would be nice if there is a way to target the process to the different parts <file>.<ext> to avoid some clashes.
e.g.
I have a pdf which the user has labelled document(pdf).pdf as the creator has their Windows settings on exclude showing extensions & uses extra filetype identification signals.
If I run a normal SAR in MS for pdf I'd lose both elements.


Is there anything like e.g. GetSourceSelectedFileNamesExcludeExt script function for file name selections? 
Or have I not found the way this is done?  ::)

EDIT
I am going to try StrSplit & a $anchor to see if I can target it to the correct regex selected elements... & PathGetNamePart is one of the things I should be thinking about!

Jungle:
Is that what you are looking for?

Ulfhednar:
Thanks Jungle. 
I had finally got round to that when I saw your post!  ::)
I thought I recalled something of the sort but was not looking in the right section!

Ulfhednar:
I managed to do what I wanted by using several passes in the script.
The biggest question I had was trimming extraneous characters like a trailing whitespace or brackets.

I used

--- Code: ---@var $re = "(docx$|pdf$|txt$)";
@var $reWS = "\s+\.";
--- End code ---
to identify file exts to a regex & then ".$1" to ensure a dot was next to that ext.

Wondered if there was a better way. 
I know it is possible to exclude the ext from the rename pass outside MS, & that this way means I must specify the exts for the regex.

I had wondered about StrSplit, but having got the array I couldn't get it to re-assemble after the renaming pass on array element 0.
i.e.
file-name.ext
output to -
0 = file-name
1 = ext

Is there a function to rejoin 0 & 1 + add/keep a . delimiter?
Thanks in advance!

Ulfhednar:
 ::)  OK I think I should just have recalled the discussion on
PathGetFileExtPart
 :-[
 ;)

Navigation

[0] Message Index

[#] Next page

Go to full version