Copy Filename without Extension

I wanted to assign a shortcut to copy filenames

I used the command:
Clipboard COPYNAMES=nopaths

But, it copies the extension also..
How to copy the filename, without the extension?

You can use the new Clipboard REGEXP argument to do this:

Clipboard COPYNAMES=nopaths REGEXP "(.*)\.[^.]*" "\1"

Anything which doesn't match the regexp will be added to the list as-is so the above command works correctly both for file/folder names which do contain an extension and for those that don't.

Or

Clipboard SET {O|noext}

Note: O above is upper-case

The commands we've both given are slightly different:

Mine will give you each filename on a separate line without any quotes.

W0lfdale's will give you all the filenames on a single line, and filenames that contain spaces will be quoted.

Which works best depends on what you're going to do with the names.

[quote="nudel"]The commands we've both given are slightly different:

Mine will give you each filename on a separate line without any quotes.

W0lfdale's will give you all the filenames on a single line, and filenames that contain spaces will be quoted.

Which works best depends on what you're going to do with the names.[/quote]
Good point, haven't realized the difference.

Thanks! Don't need the quotes... so, used the first one :slight_smile:

[quote="nudel"]You can use the new Clipboard REGEXP argument to do this:

Clipboard COPYNAMES=nopaths REGEXP "(.*)\.[^.]*" "\1"

Anything which doesn't match the regexp will be added to the list as-is so the above command works correctly both for file/folder names which do contain an extension and for those that don't.[/quote]

Need a small modification to this...

In case, a filename with .(period) is copied, it ignores the part which follows the .(period)

Eg. If I copy "XYZ.123.mp3"
it copies XYZ
I would like to copy XYZ.123

Thanks in Advance!

If geting the names horizontally or vertically makes no difference to you, then the second command I provided avoids this situation, and if you need to get rid of the quotes, then use the following:

@nofilenamequoting Clipboard SET {O|noext}

[quote="nudel"]You can use the new Clipboard REGEXP argument to do this:

Clipboard COPYNAMES=nopaths REGEXP "(.*)\.[^.]*" "\1"

Anything which doesn't match the regexp will be added to the list as-is so the above command works correctly both for file/folder names which do contain an extension and for those that don't.[/quote]
BTW, this regexp should work as the user expects truncating only the section containing the last period, but it seems the engine works in non-greedy mode, and that's strange because the default is the greedy mode and the ? should direct the engine to work in non-greedy mode.

[quote="W0lfdale"]
If geting the names horizontally or vertically makes no difference to you, then the second command I provided avoids this situation, and if you need to get rid of the quotes, then use the following:

@nofilenamequoting Clipboard SET {O|noext} [/quote]

Tried this!
It works great with Filenames
But, when I copy Foldernames, the part following the .(period) is not copied
He hee.. this is getting funny :laughing:

If you want to use the regexp version then this fixes the problem (just needs a $ at the end):

Clipboard COPYNAMES=nopaths REGEXP "(.*)\.[^.]*$" "\1"

This will definitely chop off the "extensions" on folder names as well, though.

@To GP Software

The regexp used with the clipboard raw cmd doesn't work properly with the . (dot) character (works in non-greedy mode b default), but it works properly if you replace the . (dot) with another character.

Just a correction, if you apply the following command:

Clipboard COPYNAMES=nopaths REGEXP "(.*)\.[^\.]*" "\1"

on the following file name:

New.Text.Document.txt, the result is:

New.Text

I guess this means the regexp is applied internally on the file name without the ext.

Why not just use the Print Folder command and tell it not to show anything other than filenames without extensions and to output to the clipboard ?

If i want to copy the filename, without the extension, into Clipboard

I use this command (only for one file)

@nodeselect @nofilenamequoting Clipboard COPYNAMES=nopaths REGEXP "(.*)\.[^.]*$" "\1"

If i want to paste this i use

@nodeselect @nofilenamequoting Rename PATTERN "{file$|noext}.*" TO "{clip}.*" AUTORENAME

and if i want to add an extra text (clipboard+text) i use (only for one file)

@nodeselect @nofilenamequoting Rename PATTERN "{file$|noext}.*" TO "{clip}{dlgstring|Extra Text}.*"

But if you select multiple files can be inserted at the request different texts?

You can modify this command so that on the basis of selected files you ask me what to put

Rename PATTERN "{file$|noext}.*" TO "{clip}{dlgstring|Extra Text}.*"

example

movie.avi <--- Copy This into clipboard

now select all this file

AAAAA.ccd
BBBBB.srt
CCCCC.txt

now display a dialog prompting that asks what insert (In this case, I ask 3 times what I put)

and In addition to the clipboard wish to add these portions of text: " eng" " sub" " extra"

and the result

movie eng.ccd
movie sub.srt
movie extra.txt

It's possible?

Thanks

I'd say the best way to do that is using a VBScript rename preset. If you know VBScript then it should be fairy easy (but if not then I guess it won't be). Here are some existing scripts to look at as a starting point:

[ul][li]From file rename script[/li]
[li]TitleCase[/li]
[li]Script to perform multiple Regular Expressions[/li][/ul]
The first one is probably closest to what you want to do, though I have not looked at the code inside it.

Thanks..but i don't know VBscript

== good reason to learn a little of it :smiley: