{clip} returns copied name, but if there is space in name, Select PATTERN {clip}* does not work

I am using {clip} to return a copied name to the clipboard, it works fine except that if there is space in the copied name then the SELECT PATTERN command becomes unable to match the copied name.

For example:
I copied a name called test123
If I use Select PATTERN {clip}* , it selects all files that have test123 in the name.
However, if I copy the name with space "test 123" instead of "test123", the command Select PATTERN {clip}* becomes unable to select the files with similar name.

{clip}, although it returns the name with a space (test 123), cannot select files with a space added.

That's why quotes were invented :slight_smile:

1 Like

I can't believe I forgot quotes :no_mouth:

I'm trying to clear the clipboard because Select is selecting previous files.
However, I didn't find in the manual an argument to clean the clipboard, isn't that possible?

Do you want to clear the clipboard or the file selection?

1 Like

Clipboard

I think Clipboard SET always wants to put something in the clipboard, so if you really need an empty clipboard you'd need to use a script. However, I don't see what this has to do with selecting files :thinking:

1 Like

I am using the following function to copy a part of the selected file name

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

So with the function below, I try to select all files that contain the name copied from the clipboard

Select PATTERN "{clip}*"

However, when using the function more than once, it selects two groups of files, it is selecting a file copied to the clipboard previously, along with the new file copied to the clipboard.

For example:
I copied a file named "test" and run Select PATTERN "{clip}*" to select files with a similar name. But, if now I want to repeat the same procedure with a file with a different name (abc2), the function Select PATTERN "{clip}*" starts to select files with the new name (abc2), and also with the old one (test)

Select does not select it, it rather does not deselect it. Try adding DESELECTNOMATCH.

1 Like

I'm sorry, the names I suggested in the example were just for simplicity, but the function I put can select the files.

the names on the right are the real ones, those on the left were the examples I gave
test = test1.0
abc2= abc2.0

DESELECTNOMATCH is selecting the filename previously copied to the clipboard instead of the new one.

I'm not sure at all what is causing problems here.

Select PATTERN "{clip}*"

This is working fine for me when one file is selected to the Clipboard COPYNAMES=nopaths REGEXP ([^\.]*)\..* \1

When more than one file is selected, the second command Select PATTERN "{clip}*"
no longer makes sense. The clipboard then has multiple lines.
The Select command then does nothing.

DESELECTNOMATCH 

Sorry, a good guess I think, but I'm afraid it is moot.
Sorry, these two commands are working here unless I'm misunderstanding something.

1 Like

When more than one file is selected, the second command Select PATTERN "{clip}*"
no longer makes sense

I'm not trying to run the function on two files with different names at the same time, but only one at a time, as I need to use the command multiple times on different files.

If I select a file called "test1.0" and run the functions Clipboard COPYNAMES=nopaths REGEXP ([^\.]*)\..* \1, and Select PATTERN "{clip} * ", files that contain "test1" in the name will be selected.
But if now I want to perform the same procedure with a different file, I will deselect the previous files and select the new file named "abc2.0" and I will execute the Clipboard and Select functions again. But instead of selecting only files with "abc2" in the name, groups of files containing "test" and "abc2" will be selected. When giving this "error" and clicking outside, unmarking the selected files, and selecting the desired file again (abc2.0) and executing the functions, everything happens normally, without errors, selecting only the files with "abc2" in the name.

Executing the function Select DESELECTNOMATCH PATTERN "{clip}*", when selecting the desired file, it automatically deselects the file, so if I select the file again and execute the function, everything happens normally. I thought that the name of the previous file could be stuck in the clipboard, being necessary to execute the function twice, but I did a test with the same file and the same behavior happens.

If I put DESELECTNOMATCH at the end of the function and run it a second time on a different file, then instead of selecting the current filename it selects the previous filename
Select PATTERN "{clip}*" DESELECTNOMATCH

In most cases, parameters like DESELECTNOMATCH can be placed anywhere you want. Differences in execution will be caused by something else.

1 Like

I can't detect where I'm going wrong, it's like there's a history on the clipboard with several names there, interfering with the command in several ways.

Clipboard COPYNAMES=nopaths REGEXP ([^\.]*)\..* \1 
Select PATTERN "{clip}.0*" DESELECTNOMATCH

{clip} is evaluated before any commands are run, so changing the clipboard content in the same command that uses it won't work. (And is also a bad idea: Commands should not use the clipboard as a variable just to pass things from one line in the command to another. You might have something in the clipboard you want to keep, and you'll lose that every time you use the button, when the button's aim is selecting things, not changing the clipboard.)

But you can do what you want using a simple script. We can help with that if you link your account.

(Edit: I may have been incorrect about when {clip} is evaluated. Seems it's when each line is run, not before the whole command. It's still a bad idea to use the clipboard to build commands when there are much better ways, it can work even if it's not the best way.)

1 Like

I'm a bit confused now.

I had thought this was two buttons.
The first command Clipboard COPYNAMES=nopaths REGEXP ([^\.]*)\..* \1 was the solution in this thread. I made a second button to test the Select PATTERN "{clip}*".

My answer was based on using one button to copy the Regular Expression to the clipboard and then a second button to do the Select command from the clipboard. That works fine here.
So is this one button or two ?

1 Like

Any suggestions on how to do it via script, since {clip} is not ideal?

One button. However, when running it with a new file, it interacts with the old one, even if the old one is unselected.

Thanks for linking.

Re-reading the thread in detail, I'm not really sure what you're trying to do at this point.

Could you explain it in a single post?

Edit: Thread continues here -> Select files that contain name similar to the selected file

1 Like