Basic Long File Path Search and Just Truncate to Shorter Name?

Advanced Renamer forum
#1 : 01/05-23 08:33
Jason Ro
Jason Ro
Posts: 1
Hi -

Am just trying to bulk locate and rename via truncation long file names on my Windows machine so I can adhere to the 256 character limit;

I don't need complex renaming, just basically locate the long files and then chop off, say 50 characters at the end of the long ones.

Is there a preset for this ? I've looked on Youtube thinking this would be a very common need for basic users, but can't find anything about this

Thanks

Jason


01/05-23 08:33
#2 : 01/05-23 14:46
David Lee
David Lee
Posts: 1125
Firstly - just a couple of comments...

1) The 256 character limit applies to the total file path and not just the filename - eg: "this\is\a\complete\path\including\file.name".
(The full path is preceded by the volume (eg "C:\") and terminated by a Null character so that the maximum pathlength is actually defined as 260 characters).

Thus the number of characters available for the filename itself will depend on the depth of the folder tree and the length of the sub-folder names. So a filename that is perfectly acceptable at the root of a volume may be too long if you try to move it deep within the file structure.

2) The 256 character limit used to be a basic feature of the Windows filesystem. However, starting with Windows 10, Version 1607, this restriction has been removed (leading to a physical pathname limit of more than 32,000 characters). However, for reasons of backwards compatibility, the maximum allowed path length is still restricted to a value set by the variable MAX_PATH, which by default is set to 260 characters. This restriction can now be removed by a modification to the registry - or by using the Group Policy Editor (if available). See https://learn.microsoft.com/en-us/windows/win32/ fileio/maximum-file-path-limitation (or a Google search) for further details.

----------------------------------

That said, it would be fairly straightforward to achieve what you ask using a Script method, although it would be somewhat complex.

An easier solution would be to set a maximum filename length and truncate your existing filenames appropriately using a "New Name" method and the <Substr> tag.

eg - to truncate your filenames to 100 characters., simply use...

New Name: <Substr:1:100>

This will return up to the first 100 characters of the filename - filenames shorter than 100 characters will not be affected.



01/05-23 14:46 - edited 01/05-23 19:31