XYplorer hangs on execution of the script of the following content:
(XYplorer must
- find *.jpg- and *.txt-files,
- calculate their number and length,
- write these data into a file.
Hangs occurs if the number of file is over 4500.
If the amount of files is under 4500 XYplorer does not hang and works properly.)
Code: Select all
$dateandtimeofstart = <date yyyy.mm.dd hh.nn.ss>;
$dateforfile = gettoken ("$dateandtimeofstart",1," ",,);
$timeforfile = gettoken ("$dateandtimeofstart",-1," ",,);
$dateandtimeforfilename = "$dateforfile-$timeforfile";
$folder = "C:\folder\";
$searchresultjpg = quicksearch ("*.jpg /f", "$folder",<crlf>);
$filecountjpg = gettoken ("$searchresultjpg","count",<crlf>,,);
$i1 = 1;
while ($i1 < "$filecountjpg" + 1) {
$line = gettoken ("$searchresultjpg",$i1,<crlf>);
$filesize = filesize ($line);
$sumsizejpg = "$sumsizejpg"+"$filesize";
$i1++;
}
$searchresulttxt = quicksearch ("*.txt /f", "$folder",<crlf>);
$filecounttxt = gettoken ("$searchresulttxt","count",<crlf>,,);
$i2 = 1;
while ($i2 < "$filecounttxt" + 1) {
$line = gettoken ("$searchresulttxt",$i2,<crlf>);
$filesize = filesize ($line);
$sumsizetxt = "$sumsizetxt"+"$filesize";
$i2++;
}
writefile("C:\folder-1\$dateandtimeforfilename-files.txt","$folder<crlf>*.jpg $filecountjpg $sumsizejpg<crlf>*.txt $filecounttxt $sumsizetxt<crlf><crlf>",a,t);
$dateandtimeofend = <date yyyy.mm.dd hh.nn.ss>;
writefile("C:\folder-1\$dateandtimeforfilename-files.txt",">-$dateandtimeofstart<crlf>->$dateandtimeofend<crlf><crlf>",a,t);
msg Script executed!;
Should the sum of the file lengths be calculated in this script in an another way?
In the Info Panel the files are found very quickly and the sum of the lengths of the founded files is calculated automatically, very quickly, without problems.
It should be possible to get the sum of file lengths without hangs.
XYplorer Beta Club