# How to quickly remove a file/folder from Global Filters

**URL:** <https://resource.dopus.com/t/how-to-quickly-remove-a-file-folder-from-global-filters/41038>\
**Category:** Help & Support\
**Created:** [April 14, 2022, 7:02pm UTC](https://resource.dopus.com/t/how-to-quickly-remove-a-file-folder-from-global-filters/41038 "2022-04-14T19:02:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SomeYoungGuy](https://resource.dopus.com/user_avatar/resource.dopus.com/someyoungguy/32/68846_2.png) [@SomeYoungGuy](https://resource.dopus.com/u/SomeYoungGuy)\
**Post date:** [April 14, 2022, 7:02pm UTC](https://resource.dopus.com/t/how-to-quickly-remove-a-file-folder-from-global-filters/41038/1 "2022-04-14T19:02:54Z")

</div>

I posted a question about quickly hiding a file or folder using a hotkey, and adding them to my **Global Filters** here:

> [@Select multiple files, press hotkey to add those files to Global File Filters](https://resource.dopus.com/t/select-multiple-files-press-hotkey-to-add-those-files-to-global-file-filters/24912):
>
> I would like to be able to select multiple files in a Lister, then press a hotkey or a toolbar button which would automatically add those files to the Filename Global Filters (I want the selected files to be hidden). I am currently copying-and-pasti…

Now if I want to view (unhide) a file or folder that is hidden by a **Global Filter** , I either press a hotkey which disables all **Global Filters** by activating this command:

```auto
Set GLOBALHIDEFILTER=Toggle

```

... or I click on an entry in my status bar which activates this command:

```auto
{hi}

```

Is there a command or a way that would let me perform the opposite action? That is, can I _ **remove** _ a file or folder from the **Global Filters** using a hotkey? I am currently doing the following to remove a file from the **Global Filters** :

1. I unhide a file in a Lister.
2. Copy the file name to the clipboard.
3. Open _ **Preferences \> Global Filters** _, then copy all of the text in the **Filename:** edit field to the clipboard.
4. Paste the text to a text file, then open it.
5. Search for the file name I want to remove, delete it, then copy the remaining text to the clipboard.
6. Paste the text back to the **Filename:** edit field, then save my changes.

This is a tedious process. Any help would be greatly appreciated! Thanks.

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [April 14, 2022, 7:18pm UTC](https://resource.dopus.com/t/how-to-quickly-remove-a-file-folder-from-global-filters/41038/2 "2022-04-14T19:18:18Z")

</div>

Nothing stops the same script from removing things from the pattern in the same way it adds them, so you could do it like that.

Using the Hidden attribute, that exists for this kind of thing, would be a lot easier though!

---

<div class="post-metadata">

**Author:** ![SomeYoungGuy](https://resource.dopus.com/user_avatar/resource.dopus.com/someyoungguy/32/68846_2.png) [@SomeYoungGuy](https://resource.dopus.com/u/SomeYoungGuy)\
**Post date:** [April 14, 2022, 7:47pm UTC](https://resource.dopus.com/t/how-to-quickly-remove-a-file-folder-from-global-filters/41038/3 "2022-04-14T19:47:15Z")

</div>

Hmmm... This is the script I am using that adds files/folders to the Global Filters:

```auto
Option Explicit

Function OnClick(clickData)

	Dim flt, vecFiles, vecDirs, f, cmd, c
	Set flt = DOpus.filters
	Set vecFiles = DOpus.Create.Vector
	Set vecDirs = DOpus.Create.Vector

	c = 0
	for each f in clickData.func.command.files
		if f.is_dir Then
			vecDirs.push_back(f.name)
		else
			vecFiles.push_back(f.name)
		end if
		c = c + 1
	next

	if c > 0 Then
		clickData.func.command.ClearFiles
		if not(vecDirs.empty) then AddToFilter flt.folder, vecDirs, clickData.func.command, "GLOBALHIDEFOLDERS"
		if not(vecFiles.empty) then AddToFilter flt.file, vecFiles, clickData.func.command, "GLOBALHIDEFILENAME"
		if not(flt.enable) then clickData.func.command.AddLine("Set GLOBALHIDEFILTER on")
		clickData.func.command.Run
	end if

End Function

Function EscapeFilename(strName)
	strName = Replace(strName, "'", "''")
	strName = Replace(strName, "#", "'#")
	strName = Replace(strName, "(", "'(")
	strName = Replace(strName, ")", "')")
	strName = Replace(strName, "~", "'~")
	strName = Replace(strName, "[", "'[")
	strName = Replace(strName, "]", "']")
	EscapeFilename = strName
End Function

Function AddToFilter(strPattern, vecItems, cmd, arg)

	Dim f, existingMatches, setNewMatches
	
	if Left(strPattern, 1) = "(" then strPattern = Right(strPattern, Len(strPattern) - 1)
	if Right(strPattern, 1) = ")" then strPattern = Left(strPattern, Len(strPattern) - 1)
	existingMatches = Split(strPattern, "|")

	Set setNewMatches = DOpus.Create.StringSetI
	for each f in existingMatches
		setNewMatches.insert(f)
	next

	For each f in vecItems
		setNewMatches.insert(EscapeFilename(f))
	Next

	strPattern = "("
	for each f in setNewMatches
		if Len(strPattern) > 1 Then strPattern = strPattern & "|"
		strPattern = strPattern & f
	next
	strPattern = strPattern & ")"

	cmd.AddLine "Set " & arg & " """ & strPattern & """"
	
End Function

```

Are you saying I could modify this script to do the reverse (_ **unhide** _ instead of hide)? If so, could you tell me how to do this? Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [April 14, 2022, 7:56pm UTC](https://resource.dopus.com/t/how-to-quickly-remove-a-file-folder-from-global-filters/41038/4 "2022-04-14T19:56:40Z")

</div>

Yes, exactly. Not knowing how much scripting experience you have, which part(s) do you need help with?

---

<div class="post-metadata">

**Author:** ![SomeYoungGuy](https://resource.dopus.com/user_avatar/resource.dopus.com/someyoungguy/32/68846_2.png) [@SomeYoungGuy](https://resource.dopus.com/u/SomeYoungGuy)\
**Post date:** [April 14, 2022, 8:33pm UTC](https://resource.dopus.com/t/how-to-quickly-remove-a-file-folder-from-global-filters/41038/5 "2022-04-14T20:33:48Z")

</div>

I have no scripting experience. I don't want to take up your time, I just thought I could modify the same script that adds objects to the Global Filters. Thank you.
