Copy files/directories from src to dest but ignore 1 filetype

I've made/copied a file/folder context menu item that copies selected files/folders from source to destination.

I'm pretty sure I copied it from these forums:

@keydown:none
Copy
@keydown:shift
Copy AS

But I'd like to make a specialized context-menu command that copies selected files from source to destination, but ignores any files that end in .xlsx (for example).

I think I need a script for this, but I am not sure how to use a script to get a "hook into" the destination.
I've found this script (code shown below) which shows me how to get the selected source files, but I'm not sure how to get the destination info.

Any thoughts?

TY!


Function OnClick(ByRef clickData)
   If clickData.func.sourcetab.selected_files.count = 0 Then
      Msgbox "Nothing is selected",16, "NO FILE SELECTED"
	  End If
ClipString = ""
For Each SelectedItem In ClickData.Func.sourcetab.Selected
     dato = SelectedItem.create
     ClipString = SelectedItem.name_stem
	 exto = SelectedItem.ext
'Discover the creation date of the file
	 pluggo =selectedItem.modify 
	 pluggo = Cstr(pluggo)
	 pluggo = Left(pluggo,10)
	 pluggo =Right(pluggo,4)
msgbox clipstring + "     " +  exto   + "     " + pluggo
Next
End Function

How about..

copy filter {dlgstring|Enter filter|~(*.xlsx)}
1 Like

Thank you for the suggestion, but that's not quite what I'm looking for (and I don't completely understand the syntax).
If I understand correctly, dlgstring will pull up a dialog box and ask me to enter a file name and then it will ignore files that end in .xlsx (although I'm not sure I understand the |~ syntax (is that part of a regex?)).

The code below almost works, but it has a problem with paths that contain "spaces."

Function OnClick(ByRef clickData)
	'Msgbox clickData.func.desttab.path
	For Each SelectedItem In ClickData.Func.sourcetab.Selected
		clickData.func.command.RunCommand("copy " & SelectedItem.name & " " & clickData.func.desttab.path) ' doesn't seem to work on that contain spaces
     	'Msgbox SelectedItem.path
		'ClipString = SelectedItem.name_stem
		'exto = SelectedItem.ext
		'selected_dirs
		'selected_files
	Next	
End Function

What are you looking for that it doesn't do?

This avoids the dialog

Copy FILTER ~(*.xlsx)
1 Like

Thank you. I was writing a script that was monumentally more complicated than that, but that works perfectly.

Thank you to @aussieboykie as well