How to find a strings and replace with nothing from file name without any confirmation?

The file name is
Avatar_download_from_www.demodata.com
Inception_download_from_www.demodata.com
Avengers_download_from_www.demodata.com

I want a dialog box where I input the String _download_from_www.demodata.com
Then Press Enter will Remove the String from any where from the Selected File Names

Easier to remove the characters via the Rename dialog's preview list, since you'll have to do something similar just to get the text you want to remove into the clipboard:

Hi Leo
The String can be any where in the file name. I mean not in the same place.
example:
1 My Name is Khalid _download_from_www.demodata.com
2 My Name _download_from_www.demodata.com is Khalid
3 My _download_from_www.demodata.com Name is Khalid
So Rename dialog's preview list not working in this case.

Plz Notice that i said " Remove the String from any where from the Selected File Names"

You could use the Find & Replace mode to do that easily.

If you want a button to do it with less typing, what have you tried so far? Which part are you stuck on?

I am Stuck on Confirmation. If I select Multiple file then use this button then each file wants a Confirmation "OK" . But I want the Multiple Selected File Will Works without Confirmation OK for each file. Here is the Rename Preset Code:

<?xml version="1.0" encoding="UTF-8"?>
<rename_preset autorename="yes" case="none" script="yes" type="normal" typeval="0">
	<from>*</from>
	<to>*</to>
	<script>@script vbscript 
Option Explicit 

Dim Recherche, Texte, Txt
Dopus.OutputString &quot;Script: PE4_Replace - Written by: Albator V&quot;

Function Rename_GetNewName ( strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName ) 

If Len(Recherche) = 0 Then 
   Txt = vbcr &amp; vbcr &amp; &quot;Find What? (Entries are Case Sensitive)&quot;
   Recherche = inputbox (Txt, &quot;Replace&quot;,&quot;&quot;)
   If Recherche = &quot;&quot; Then Exit Function 
End if 
If Len(Texte) = 0 Then 
   Txt = vbcr &amp; &quot;Rplace With....&quot;&amp; vbcr &amp; vbcr &amp; &quot;You can leave this box empty for replace with nothing. String to replace : &quot; &amp; Recherche
   Texte = inputbox (Txt, &quot;Replace&quot;,&quot;&quot;) 
End if 

Dim Ext, NomFichier

If fIsFolder = False Then &apos;if folder, extension = nothing
    Ext = Right (strFileName, Len(strFileName) - (InStrRev(strFileName, &quot;.&quot;) - 1))
Else
    Ext=&quot;&quot;
End if

NomFichier = Left (strFileName, Len(strFileName) - Len(ext))

If Recherche = &quot;&lt; All &gt;&quot; Then
	strNewName = Texte
Else
	strNewName = replace(NomFichier, Recherche, Texte)
End if

strNewName = replace(strNewName, &quot;&lt; Nothing &gt;&quot;, &quot;&quot;) &amp; Ext

End Function </script>
</rename_preset>

That's the 4th preset from Rename Toolbar v3 (english and french) without any real changes to the code.

Trying the original, it seems to work fine as-is. It only prompts for the first file and then applies the same things to all the others. (It asks for the search string, then the replacement string, but only once for each.)

If you don't want it to prompt for the replacement string, it's a fairly simple change.

Although I would do things differently, without using a script for any of this, since you can do it in a simple, single-line button or hotkey:

Rename FINDREP PATTERN="{dlgstring|Enter text to remove:}" TO

Everything in that line is explained under:

1 Like

Thanks for the nice simple, single-line Command