Everything Rename in Windows Context Menus

Discussion related to "Everything" 1.5 Alpha.
Post Reply
MandraK
Posts: 21
Joined: Mon Jan 06, 2020 4:45 pm

Everything Rename in Windows Context Menus

Post by MandraK »

I just had an issue with EV file rename in v1.5.1341 that made me roll back to v1.5.1340 where it doesn't happen.

I use a VBS script to load files and folders to "everything64.exe -rename" from Windows context menus.
But this somewhat stopped working with version v1.5.1341, although it still works perfectly from the EV interface.

When I say stopped working I mean that when changing text in the the Edit3 input text control, filenames are
not instantly changed within the Edit4 textbox control. But in the previous version (v1.5.1340) it still works.

This is an example of the command sent to EV (within the VBS script) to start rename:

Code: Select all

$ everthing64.exe -rename "file 1.ext" "file 2.ext" "file 2.ext" "folder 1" "folder 2"
This is the full VBS script used in context menus (EVContextRename.vbs):

Code: Select all

'+===============================================
'| EVContextRename
'| Date	 2019-10-28 22:35
'| Last	 2023-04-10 08:53
'| Author	 Melvin D. Nava <mdnava[at]gmail.com>
'| URL		 https://www.mdnava.com/
'+===============================================
'| Rename files/folders from context menus
'| 
'| Important: There is a maximum of 32767 chars for command-line arguments (8192 if using cmd.exe).
'| Ref: https://devblogs.microsoft.com/oldnewthing/20031210-00/?p=41553
'| 
'| Requires:
'| 	<everything.exe>       https://www.voidtools.com/
'| 	<singleinstance.exe>   https://github.com/ge9/SingleInstance-Launcher
'| 
'| Usage (in the Windows Registry):
'| 	$ singleinstance.exe \"%1\" \"D:\\path\\to\\EVContextRename.vbs\" $files --si-timeout 400"
'+============
Option Explicit
If WScript.Arguments.Count < 1 Then MsgBox "Missing parameter, nothing to do!.", vbInformation, "Notice" & WScript.Quit()
Dim objFSO, objShell, envDesktopPath, arrArgs
Set objFSO		= CreateObject("Scripting.FileSystemObject")
Set objShell	= CreateObject("WScript.Shell")
Set arrArgs		= Wscript.Arguments
EVContextRename()

' ===========================
' == Main Subroutine ========
' ===========================
Public Sub EVContextRename()
	Dim sScriptFolder, sArg, sVar
	Dim nSubFolderCount, nFileCount, nTotalCount
	sScriptFolder	= objFSO.GetParentFolderName(objFSO.GetFile(Wscript.ScriptFullName))
	nSubFolderCount	= 0
	nFileCount		= 0
	nTotalCount		= 0

	'** If argument is a single folder, get all its files (but no subfolders)..
	If objFSO.FolderExists(arrArgs(0)) And WScript.Arguments.Count = 1 Then
		Dim objFolder, objSubFolders, objFolderFiles, pFolderPath, f
		Set objFolder		= objFSO.GetFolder(arrArgs(0))
		Set objSubFolders	= objFolder.SubFolders
		Set objFolderFiles	= objFolder.Files
		pFolderPath			= objFSO.GetAbsolutePathName(objFolder)
		nSubFolderCount		= objSubFolders.Count
		nFileCount			= objFolderFiles.Count
		nTotalCount			= nSubFolderCount + nFileCount
		objShell.CurrentDirectory = pFolderPath

		For Each f in objFolderFiles '** Add files from folder
			sVar = sVar & " """ & objFSO.GetAbsolutePathName(f.Name) & """"
		Next

		If sVar = "" Then '** If there are no files, try to add subfolders
			For Each f in objSubFolders '** Add subfolders from folder
				sVar = sVar & " """ & objFSO.GetAbsolutePathName(f.Name) & """"
			Next
		End If

	Else '** Handle any selected files or folders (sent as arguments)
		For Each sArg In arrArgs
			If objFSO.FileExists(sArg) Or objFSO.FolderExists(sArg) Then
				sVar = Replace(sVar, "file:///", "") '** For CopyQ
				sVar = Replace(sVar, "file://", "")
				sVar = sVar & " """ & sArg & """"
				nFileCount = nFileCount + 1
			End If
		Next
	End If

	sVar = Trim(sVar)
	If sVar = "" Then WScript.Quit

	If Len(sVar) > 32750 Then ' Stop at a bit less chars than allowed
		WScript.Echo "There are too many arguments, try selecting less elements: " & vbCrLf & vbCrLf & _
			Len(sVar) & " characters (limit: 32750)" & vbCrLf & _
			nFileCount & " files" & vbCrLf
			'nSubFolderCount & " folders" & vbCrLf
		WScript.Quit
	End If

	objShell.Run sScriptFolder & "\Everything64.exe -rename " & sVar, 1, False
End Sub

Set objFSO   = Nothing
Set objShell = Nothing
I also use the CTRL+R AutoHotkey keyboard shortcut in File Explorer (Global.ahk):

Code: Select all

; ============================================
; AutoHotkey
; Everyting Rename on File Explorer [CTRL+R]
; ============================================
#If IsAnyFileExplorer() And Not Winactive("ahk_exe Everything64.exe") ; EV already has CTRL+R set up
^R::
EverythingRename() {
	Local sSelectedFiles := GetSelectedFiles()
	
	If (sSelectedFiles = "")
		sSelectedFiles := """" . GetCurrentPath() . """"

	If (sSelectedFiles != "") And (sSelectedFiles != "ERROR")
		Run(EnvGet("EVERYTHING_HOME") . "\EVContextRename.vbs " . sSelectedFiles)

	Return
}
#If
Best regards!
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Everything Rename in Windows Context Menus

Post by NotNull »

This is actually a new bug in version 1341. It will be fixed in the next version. This thread has more info on the matter.
MandraK
Posts: 21
Joined: Mon Jan 06, 2020 4:45 pm

Re: Everything Rename in Windows Context Menus

Post by MandraK »

NotNull wrote: Mon Apr 10, 2023 2:15 pm This is actually a new bug in version 1341. It will be fixed in the next version. This thread has more info on the matter.
Understood!. Thank you.
Post Reply