Long Path Finder 0.1 (March 29, 2013)

Discuss and share scripts and script files...
Post Reply
Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Long Path Finder 0.1 (March 29, 2013)

Post by Enternal »

LongPathFinder.xys
(1.15 KiB) Downloaded 222 times
LongPathRun.xys
(1.36 KiB) Downloaded 204 times
This script allows you to find any file that has the path length longer than the length specified by you. This is generally useful if you want to know if there are any files that are longer than 256 which is the maximum path length before Windows Explorer starts to have issues with dealing with those files. Of course XYplorer can deal with long path but I made this script just to see if I can make a tool that replaces a much older tool that I have used in the past to test. Anyway, it's pretty much done and I probably won't be doing anything else to it and just decided to share it for those who wants it.

On the other hand, I also used it as a way to find a way to bypass an issue with XYplorer not being able to do much else when it's busy processing a script. The problem with finding long path is that if your system has many many files and length you specified is small (generally less than 150), the script pretty much makes XYplorer "freeze" and you can't do anything else to it until XYplorer finishes the script (which during testing with this script and my system, I had to wait for around 10 minutes) due to the amount of files it found that was longer than 150 that I had specified. Anyway, the bypassing method seems to work and the details is here:
http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=9473

Currently I have the results of the LongPathFinder saved in a text file called LongPath.txt which is automatically opened after the script finish. You can uncomment and comment this part of the code:

Code: Select all

	WriteFile("<xyscripts>\LongPath.txt","$LongCat",a,tu);
	Open "<xyscripts>\LongPath.txt";
	//Text $LongCat;
so that it will pop up a text Window with the results instead if you want while still having a hard copy in the text file.

:!: :!: Remember to be reasonable with the the length you specified. If it's too short like 50 and the folder you selected has thousands and thousands of file, XYplorer is pretty much going to hang and you will more than likely have to wait an extremely long amount of time. Furthermore, the more files it has to process, the more CPU and RAM it will consume. So don't complain to me if you decided to go to the root of your archive drive, select all, and run the script for s*** and giggles. :!: :!:

Code
The pre-run code LongPathFinder.xys:

Code: Select all

/*
Long Path Finder 0.1 (March 29, 2013) by Enternal
Files: LongPathFinder.xys, LongPathRun.xys
*/

	If Exists("<xyscripts>\LongPathLength.txt") == 1 {
		Delete 0,0,"<xyscripts>\LongPathLength.txt"; }
	If Exists("<xyscripts>\LongPathItems.txt") == 1 {
		Delete 0,0,"<xyscripts>\LongPathItems.txt"; }
	If Exists("<xyscripts>\LongPathRaw.txt") == 1 {
		Delete 0,0,"<xyscripts>\LongPathRaw.txt"; }
	If Exists("<xyscripts>\LongPath.txt") == 1 {
		Delete 0,0,"<xyscripts>\LongPath.txt"; }

	$Length = Input("Long Path Finder","Files With Path Longer Than The Specified Length Will Be Listed.<crlf>Recommend Above 150. Anything Lower Could Freeze XYplorer<crlf>If There Are Many Files.","256",s,0);
	$NTest = RegExMatches("$Length","\D"); // \D Same As [^0-9]. http://gskinner.com/RegExr/
	If ($NTest == "") {
		Continue; }
	Else {
		Msg "$Length Is NOT A Valid Numerical Value."; }
	End ($Length == 0);
	WriteFile("<xyscripts>\LongPathLength.txt","$Length",,t);
	$SelectedItems = Get("SelectedItemsPathNames","|");
	WriteFile("<xyscripts>\LongPathItems.txt","$SelectedItems",,tu);
	Run """<xypath>\<xyexe>"" /ini=""<xyini>"" /win=min /script=""LongPathRun""";
The main program LongPathRun.xys that is run from a new instance:

Code: Select all

/*
Long Path Finder 0.1 (March 29, 2013) by Enternal
Files: LongPathFinder.xys, LongPathRun.xys
*/

	Global $Files;
	$Length = ReadFile("<xyscripts>\LongPathLength.txt",t);
	$LongCat = "";
	$SelectedItems = ReadFile("<xyscripts>\LongPathItems.txt",t);
	ForEach($Item,$SelectedItems,"|") {
		If Exists($Item) == 1 {
			$Files = "$Files"."|"."$Item"; }
		ElseIf Exists($Item) == 2 {
			$FFiles = FolderReport("files","r",$Item,"r",,"|");
			$Files = "$Files"."|"."$FFiles"; } }
	$Files = FormatList("$Files","e");
	ForEach($Item,$Files,"|") {
		If Report("{Len}",$Item) > $Length {
			$LongCat = "$Item"."|";
			WriteFile("<xyscripts>\LongPathRaw.txt","$LongCat",a,tu);
			$LongCat = ""; } }
	If Exists("<xyscripts>\LongPathRaw.txt") == 0 {
		Msg "No Files With Path Longer Than $Length Found.";
		Exit "n"; }
	$LongCat = ReadFile("<xyscripts>\LongPathRaw.txt",t);
	$LongCat = Replace(FormatList("$LongCat","enq","|"),"|","<crlf>");
	WriteFile("<xyscripts>\LongPath.txt","The Following Items Have Path Longer Than $Length:<crlf><crlf>",a,tu);
	WriteFile("<xyscripts>\LongPath.txt","$LongCat",a,tu);
	Open "<xyscripts>\LongPath.txt";
	//Text $LongCat;

	If Exists("<xyscripts>\LongPathLength.txt") == 1 {
		Delete 0,0,"<xyscripts>\LongPathLength.txt"; }
	If Exists("<xyscripts>\LongPathItems.txt") == 1 {
		Delete 0,0,"<xyscripts>\LongPathItems.txt"; }
	If Exists("<xyscripts>\LongPathRaw.txt") == 1 {
		Delete 0,0,"<xyscripts>\LongPathRaw.txt"; }

	Exit "n";

highend
Posts: 14639
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Long Path Finder 0.1 (March 29, 2013)

Post by highend »

Don't get me wrong, but you'll overcomplicated it a bit :)

Code: Select all

$limit = input("Choose the character limit:", , 256, "s", , 200, 100);
	goto "?len: > $limit /r";

	$Result = report("{Path}\{Name}<crlf>");
	if ($Result != "") {
		text $Result;
	}
	else {
		status "No file(s) / folder(s) found, that exceed the limit of $limit characters", "009900", "ready";
	}
Use this one.

It's fast as hell and you (probably) don't have to start a second instance of XYplorer.

E.g. it scans my 149 GB, 15.843 folders, 88.191 files (on a SSD) in about 2 seconds...
One of my scripts helped you out? Please donate via Paypal

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: Long Path Finder 0.1 (March 29, 2013)

Post by Enternal »

.... :shock:
........ :shock:
............ :shock:

I'm speechless... that does EVERYTHING (well, it does not support multiple selection of folders or files but that just requires some change... could you tell me how to do that?) and dang it's fast!! I just go into some folder, run the script, and several seconds later (I use HDD not SDD) BAM! All the results in the search tab which makes it easy to open up the file. Amazing... :appl: So I spent a whole day working on a pretty complex script... lol.

Anyways... :biggrin:
Thank you!

highend
Posts: 14639
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Long Path Finder 0.1 (March 29, 2013)

Post by highend »

Only folders are possible (files not, quick name search doesn't operate on them). Look up the quick name search in the helpfile, if you want to get more information.

A modified script could look like:

Code: Select all

	$limit = input("Choose the character limit:", "If left empty, the default of 256 will be used", 256, "s", , 200, 100);
	$folderList = "";
	foreach ($item, <get SelectedItemsPathNames |>, "|") {
		if (exists($item) == 2) {
			$folderList = $folderList . $item . ";";
		}
	}

	$folderList = ($folderList == "") ? $folderList = "?len: > " : regexreplace($folderList, ";$", "") . "?len: > ";
	goto "$folderList $limit /r";

	$Result = report("{Path}\{Name}<crlf>");
	if ($Result != "") {
		text $Result;
	}
	else {
		status "No file(s) / folder(s) found, that exceed the limit of $limit characters", "009900", "ready";
	}
One of my scripts helped you out? Please donate via Paypal

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: Long Path Finder 0.1 (March 29, 2013)

Post by Enternal »

highend wrote:Only folders are possible (files not, quick name search doesn't operate on them). Look up the quick name search in the helpfile, if you want to get more information.

A modified script could look like:

Code: Select all

	$limit = input("Choose the character limit:", "If left empty, the default of 256 will be used", 256, "s", , 200, 100);
	$folderList = "";
	foreach ($item, <get SelectedItemsPathNames |>, "|") {
		if (exists($item) == 2) {
			$folderList = $folderList . $item . ";";
		}
	}

	$folderList = ($folderList == "") ? $folderList = "?len: > " : regexreplace($folderList, ";$", "") . "?len: > ";
	goto "$folderList $limit /r";

	$Result = report("{Path}\{Name}<crlf>");
	if ($Result != "") {
		text $Result;
	}
	else {
		status "No file(s) / folder(s) found, that exceed the limit of $limit characters", "009900", "ready";
	}
Ah yes. So it's pretty much also using the same function exists as before and built around that. Thank you.

highend
Posts: 14639
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Long Path Finder 0.1 (March 29, 2013)

Post by highend »

So it's pretty much also using the same function exists as before
Sure, If you'd try to do it with one selected file, you'd get an error message so it's necessary to do some prechecks...
One of my scripts helped you out? Please donate via Paypal

mithrin
Posts: 15
Joined: 15 Jan 2012 01:56

Re: Long Path Finder 0.1 (March 29, 2013)

Post by mithrin »

Hi, there is this older script that checks for files & folders larger than 259 characters.

Code: Select all

//ReportPathsGreater259 v2.0.xys
//Report folder and filename lengths which are larger than 259 characters
   //setting('BackgroundFileOps', 0);
   $iter=0;

   foreach($line, $filelist, "<crlf>") {

   incr $iter; incr $files;
   

   
	if ($iter > 99){
	   wait 500;
	   status "processing files: $files","FF0000",,;
	   $iter=0;
	}

    goto "?len: > 259 /r";
	//text report ("{Path}\{Name}<crlf>");
	//writefile("Report.htm", 
	$text = report("<tr>
	<td>{Name}</td>
	<td {Path}</td>
	<td {Len}</td>
	</tr><crlf>", ,
	"<table cellpadding=4>", "</table>"));
	tab ("lock", ,0);
	#351;  
	}
*/
   if ($text!="") {
      echo $text;
   }
   else {
      msg "No excessive paths / files found.";
   }


/*
Perhaps you like to implement this POC (prove of concept) code?


to show status like "In process \ - / |


Code:
 $Loop=0;
 $amount=30;
 while($Loop < $amount)
 {

 //--------------------------------
 $SBT="/"; if($SBL >4){$SBL=1;}
 if($SBL==1){$SBT="/"}; if($SBL==2){$SBT="-"};
 if($SBL==3){$SBT="\"}; if($SBL==4){$SBT="|"};
 status "In process $SBT"; wait 100; incr $SBL;
 //--------------------------------


 incr $Loop;
 }
 status "Done.";





or to show "In process ..."


Code:
 $s="";
 $Loop=0;
 $amount=30;
 while($Loop < $amount)
 {
 
    if (strlen($s)>3){$s="";}
    $s = $s.".";
    status "In process$s";
    wait 1000;
    incr $Loop;
 }
 status "Done.";
*/

pseudoz
Posts: 60
Joined: 11 Mar 2009 20:41
Contact:

Re: Long Path Finder 0.1 (March 29, 2013)

Post by pseudoz »

Made a long time ago a script but never published (I use it to detect file path > 259 chars before migrating files servers with robocopy)
Cut and paste this code in your catalog. Select one directory to scan and click to the script. Take a little coffee and a nice HTML report is generated.

If you prefer a text report uncomment the second line (usefull for copy paste in a mail or for batch processing)

Code: Select all

  goto "?len: > 259 /r";
  //text report ("{#} - {Len} caractères - {Path}\{Name}<crlf>");
  writefile("Rapport fichiers supérieurs à 259 caractères.html",report("<tr><td>{#}</td><td>{Len} caractères</td><td>{Path}\{Name}</td><td align=right>{Size MB} {dir [DIR]|}</td></tr><crlf>", , "<table border=1 style='font-family:Verdana; font-size:8px;'><TR ALIGN=CENTER><td><b>Numéro</b></td><td><b>Longueur</b></td><td><b>Fichiers</b></td><td><b>Taille</b></td></TR>", "</table>"));
  tab ("lock", ,0);
  #351;

Post Reply