#1 2022-07-29 23:19

nkormanik
Member
From: Salt Lake City
Registered: 2015-02-26
Posts: 24

Truncate Filename to 100 Characters

I downloaded some ebooks with really long file names.

Q#1.  Assume these files are in folder "c:\longnames".  How can I tell ReNamer to truncate the filenames to just the first 100 characters?

Q#2.  If the files are 'nested' deep inside a directory hierarchy (so that the total path lengths exceed 260 characters) will the suggested approach need to be modified?  Can it even be accomplished?

Thanks much!

Nicholas Kormanik

Offline

#2 2022-07-30 09:41

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Truncate Filename to 100 Characters

You may want to re-use the old answers: Long Path Solution?





 


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#3 2022-07-30 21:56

nkormanik
Member
From: Salt Lake City
Registered: 2015-02-26
Posts: 24

Re: Truncate Filename to 100 Characters

Long path problems have been a huge issue.  Google search shows so many complaints.

If files are located deep within a hierarchy, unless one knows some secret, they are pretty much stuck there.

After extensive searching for solutions, the simple answer appears to be:

\\?\

Appending that to the start of the query.

I'm still trying to figure it out.

Offline

#4 2022-08-09 01:18

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: Truncate Filename to 100 Characters

ReNamer's ability to work with long file paths was described earlier in a post #10624:

den4b wrote:

ReNamer does not support long paths (>260 characters) out of the box yet, but, nonetheless, it is possible to make it process long file paths using the "\\?\" prefix notation, as described in Windows Docs - Naming Files, Paths, and Namespaces - Maximum Path Length Limitation.

For example, if your original long path is:

C:\Very\Long\Path

Then you need to add it to ReNamer as:

\\?\C:\Very\Long\Path

A slight difficulty is adding such long paths to ReNamer, because the standard Add Files and Add Folders dialogs cannot handle the long paths yet. However, you can use Add Paths dialog from the main menu, or Export/Import table options.

To truncate each component of the path (each folder name and the file name) to 100 characters, you could use Pascal Script or Regular Expressions rules.

These rules will achieve truncation of each path component:

1) Insert: Insert ":File_FilePath:" replacing current name (skip extension)
2) Replace: Replace all "\" with "\\" (skip extension)
3) Regular Expressions: Replace expression "(\\)([^\\]{1,100})[^\\]*(\\|\Z)" with "$1$2$3" (skip extension)
4) Replace: Replace all "\\" with "\" (skip extension)

Offline

#5 2022-08-09 07:40

nkormanik
Member
From: Salt Lake City
Registered: 2015-02-26
Posts: 24

Re: Truncate Filename to 100 Characters

Thank you!  Well explained.

Keep moving forward....

Offline

#6 2022-08-09 13:44

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Offline

Board footer

Powered by FluxBB