Hi again,
Sorry for asking questions again, but once again I'm struggling with this. I'm attempting to improve the script discussed above (see below) to provide more information for the user to know which thumbs folders they should delete. The script works fine in it's original state with Marco's help, but I'd like the user to see the "date" of the thumbs folder along with the "thumbs folder", "thumbs size" and "hash" value in the "inputselect" list box.
I've had success in breaking out all the required information, but the information is in two variable lists. In both list I have the
common "hash" however. One list has many lines with this information:
Code: Select all
G:\Agent downloads\|240x180|b94829719a137547c237a3e1e3f5ea2a - thumbs folder|thumbs size|hash
and the other list has many lines in this format:
Code: Select all
18-06-2013|b94829719a137547c237a3e1e3f5ea2a - date|hash
I'd like to have a variable in a resultant list that is the following in each line: "
Code: Select all
thumbs folder|thumbs size|date|hash
I extracted the "date" and "hash" from one list, and extracted individual hashes, thumbs folders, and thumbs sizes from the other list and then tried nested foreach groups to try and meld the list to obtain the desired result with no success. Is there some way to compare the "hash" values in each variable listing and when each hash values are the same (i.e., for each case that you have identical hashes from both lists), format a new line that would be the thumbs folder|thumbs size|date|hash for each of the matching results? One reason the below nested foreach's do not work is because the hashes are not necessarily in the same order in the two list and in the XYthumb.txt generated lists ($thumbstxt)", the first two lines are "XYplorer Thumbs Index v1" and "2013-08-19 17:45:39" though with another method this probably wouldn't matter. So in essence, this means looking for the common value ($hash) from two different variable lists and when the information lines in the 2 list have the common $hash, putting together new lines in a new variable with "thumbs folder|thumbs size|date|hash" in each line if that makes sense.
Code: Select all
$selected = "";
$thumbstxt = readfile("<xythumbs>\XYthumbs.txt"); //read the XYthumbs file and assign variable text $thumbstxt;
$thumbslist = formatlist(folderreport("files:{Modified dd-mm-yyyy}|{Name}", "r", "<xythumbs>", , , "<crlf>"), "f", "<crlf>", "*.dat2"); //obtain date and hash file
$thumbsnew = "";
foreach($file, $thumbslist, "<crlf>")
{
$filedate = gettoken($file, 1, "|"); //obtain date
$filebase = gettoken(getpathcomponent($file, "base"), 2, "|"); //obtain hash file name without extension
foreach($fileline, $thumbstxt, "<crlf>") {
$filehash = gettoken($fileline, -1, "|"); //hash value from XYthumbs.txt
$thumbfolder = gettoken($fileline, -3, "|"); //thumbs folder from XYthumbs.txt
$thumbsize = gettoken($fileline, -2, "|"); //thumbs size from XYthumbs.txt
if ($filebase == $filehash); //didn't think this would work and it doesn't
$thumbsnew = $thumbsnew . "|" . $thumbfolder . "|" . $thumbsize . "|" . $filedate . "|" . $filehash . "<crlf>";
}
}
$sel_hash = inputselect("Select Thumbnails files to delete<crlf>based on thumbnail size and folder location.", $thumbsnew, "<crlf>", 2, , 700, 600, "Thumbnail File Selection");
foreach($hash, $sel_hash, <crlf>)
{
$hash = gettoken($hash, -1, "|"); //pull-out the hash only portion of line
$selected = $selected . $hash . "<crlf>"; //for testing onlly
delete 0, 0, "<xythumbs>\". $hash .".*"; //using "1" to confirm deletion for testing only, but will change to "0" to avoid prompt
$thumbsnew = regexreplace($thumbsnew, ".*".$hash.".*$\r?\n?");
}
writefile("<xythumbs>\XYthumbs.txt", $thumbsnew,);
Thanks again,
Ken