Rename Files on Sub-folders: Ignore Hidden Files

Simple feature request for when renaming files on sub-folder: do not rename hidden files. Either by default or by enabling a check-box.

You should be able to do that already using a rename script. The file attributes are available to the script via the item object for each file.

Ah... cool that even that rename mode is exposed to scripts.

Off to write a script I go...

Well, it wasn't as simple as it appears because I want to use it with sequential numbering. So, instead of just this:

function OnGetNewName(getNewNameData)
{
	if (~getNewNameData.item.attr_text.indexOf("h")) {
		return true;
	} else {
		return false;
	}
}

I grabbed a copy of Numbers Within Sub-Folder and added:

' Make sure hidden files are left completely alone.
	Dim fsz, fz
	Set fsz = CreateObject("Scripting.FileSystemObject")
	Set fz = fsz.GetFile(strFilePath + "\" + strFileName)
	If fz.attributes and 2 Then
		strNewName = strFileName
		Exit Function
	End If

You don't have to do everything in the script. The script gets passed the results of the rest of the rename dialog and can then add to, leave as-is, or cancel that for each file.

Yes, but then the counter of sequential numbering does not skip the hidden files.

On the other hand, the script is not able to handle conflicting names as well as the built-in rename.

1 Like

Oh true, good point.

Maybe the sequence should not increase if a file is skipped by a script.

1 Like

Yes, likely.