I see there is an option to add a column or use that column to search for files based on path length. However, can something similar be done to search for filename length? For example, when backing up to encrypted folders, files cannot exceed 143 characters in length, so I would like to search and file all those files that do not meet the requirements.
To follow up on this, I found out that the encrypted folder accepted file names not specifically 143 character, but actually 143 bytes. although the script is sufficient enough to calculate those bytes based on latin characters (since it's about 1 byte per character), non-English characters take up a lot more bytes usually.
For example, the following test I did with Chinese characters:
汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字字.jpg
The bytes counter (mothereff.in/byte-counter) says it is 51 characters and 145 bytes. The Name length script says it is 21 characters.
I'm not too concerned with the Name Counter script here since it works for my needs with latin characters, but is it possible to do something to count the bytes a name take up, or would that require some 3rd party tool integration?
That depends on the encoding the filesystem uses. On most Windows filesystems it would be utf16/ucs16 and typically just double the number of characters (unless surrogate pairs are involved), but if the filesystem uses utf8 it may be more variable.
Opus provides a StringTools scripting helper which lets scripts encode strings into various encodings, which could be used here.
Yes, Im pretty sure it uses UTF-8 encoding to convert text to bytes. I obviously don't know what I'm doing but I tried some of the StringTools suggestions without any luck getting results.
Option Explicit
Function OnClick(ByRef clickData)
Dim bytes
bytes = "abcdefg"
bytes = DOpus.Create.Blob(byte).size
DOpus.Output bytes
End Function
Option Explicit
Function OnClick(ByRef clickData)
Dim Text, StringTools, Strings
Text = "hfhj"
Set StringTools = DOpus.Create.StringTools
Set Strings = StringTools.Decode(Text, "utf-8")
Dopus.Output Strings.size
End Function
Oh wow, I can't believe I missed that. You guys are just making this thing do magic!
I was using some really bad workaround with regex [^\x00-\x7F]+ to find non-latin characters in combination with the original name length... can delete this stupid filter now )