Jump to content

[Resolved] Calculate file path total length and return # of characters, total?


Recommended Posts

Is there some way to right click on a file and have AI calculate the length of the filepath? i.e., that it would return the number of characters in this type of filepath:

C:\Documents and Settings\UserName\Desktop\Dante.gif = 52 characters (with or without back slashes, don't know what it should be)

I have just found a bunch of truncated song titles that I've had to go over and redo because I didn't realize the entire filepath length must be over the 256 length limit.

I'd like to be able to prevent this to happen in the future as this has been one of the unaddressed problems that have gone on forever. A simple AI script that I could then call up from the context menu would be ideal but a search on the forum for "length" turned up all sorts of interesting things but nothing that would take help with this.

Is there a feature in AI that can count this type of thing?

Thanks! :P

Edited by Diana (Cda)
Link to comment
Share on other sites

Is there some way to right click on a file and have AI calculate the length of the filepath? i.e., that it would return the number of characters in this type of filepath:

C:\Documents and Settings\UserName\Desktop\Dante.gif = 52 characters (with or without back slashes, don't know what it should be)

I have just found a bunch of truncated song titles that I've had to go over and redo because I didn't realize the entire filepath length must be over the 256 length limit.

I'd like to be able to prevent this to happen in the future as this has been one of the unaddressed problems that have gone on forever. A simple AI script that I could then call up from the context menu would be ideal but a search on the forum for "length" turned up all sorts of interesting things but nothing that would take help with this.

Is there a feature in AI that can count this type of thing?

Thanks! :oD

Firts compile script1 and save it somewhere. Compile it as diana.exe or if you use another name change the name in script 2

Script1

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=diana.exe
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
If $CmdLine[0] > 0 Then
    MsgBox(262144, "length of pathe to file is", StringLen($CmdLine[1]) & " characters")
EndIf

Then run script 2 just once to set the extra menu entry for the file explorer context menu. It must be run from the same folder as the exe is saved in which was made by script 1.

Sript 2

$KeyName = "file path length"
$ContextMenuName = "show full path length"
$ProgramToRun = @ScriptDir & "\diana.exe"
RegWrite("HKEY_CLASSES_ROOT\*\shell\" & $KeyName & "\command", '', 'REG_SZ', '"' & $ProgramToRun & '" "%1"');'passes file full path to program
RegWrite("HKEY_CLASSES_ROOT\*\shell\" & $KeyName, '', 'REG_SZ', $ContextMenuName)

Then when you right click over a file there will be a menu option to give the length of the full path to that file.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

That's really, really awesome! It works like a charm.

I just renamed the second script to this:

"Set filepath length calculator to context menu.au3" so that next OS reinstall, easier to remember which does which <g>.

Now to go and move my MP3s around and see which ones I'll need to fix out of the very long names <sigh>. That should be a couple of hours of fun work! <g>

Thanks! :P

Link to comment
Share on other sites

  • 1 year later...

Is there some way to right click on a file and have AI calculate the length of the filepath? i.e., that it would return the number of characters in this type of filepath:

C:\Documents and Settings\UserName\Desktop\Dante.gif = 52 characters (with or without back slashes, don't know what it should be)

I have just found a bunch of truncated song titles that I've had to go over and redo because I didn't realize the entire filepath length must be over the 256 length limit.

I'd like to be able to prevent this to happen in the future as this has been one of the unaddressed problems that have gone on forever. A simple AI script that I could then call up from the context menu would be ideal but a search on the forum for "length" turned up all sorts of interesting things but nothing that would take help with this.

Is there a feature in AI that can count this type of thing?

Thanks! :D

Hi There,

Oh Wow, I've been looking for a utility to do EXACTLY this, literally for weeks now.., I use external usb hard drive to copy files and if the path is too long there are problems and md5 hash file integrity returns incorrect, I will try this but just in case I wanted to ask you ,were you able to find any other freeware utility or such that can do the same thing ?

Thanks

Link to comment
Share on other sites

The easiest way would be to compile this code and save it as Path_Len.exe. Creae a Send To shortcut (Path Length} for it and then just right-click any file or folder and choose Send To >> Path Length

If $CmdLine[0] > 0 Then MsgBox(4096,"Path Length", StringLen($CmdLine[1]) & " characters."

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...