ZoomtoFillFolderThumbs [Script]

Discuss and share scripts and script files...
Post Reply
klownboy
Posts: 4142
Joined: 28 Feb 2012 19:27

ZoomtoFillFolderThumbs [Script]

Post by klownboy »

This script will generate thumbnails for all your subfolders (not files) under the current folder in a Zoom to Fill mode. See the example differences below.
- It randomly selects a image in each subfolder.
- The new thumbnails will be called folder.jpg. Any existing folder.jpg files will be renamed not deleted.
- The size of the thumbnail for the subfolders will be auto detected based on thumbnail size assigned for the current folder times a multiple 4 (default), though the multiple can be "1" (see $multiple below).
- First, go to the main folder where you have subfolders under it (e.g., G:\Wallpaper or H:\Photos).
- Ensure the view is a thumbnail viewing mode more than likely you would be or should be via a Folder View Settings or tab.
- If not in a thumbnail mode the script will exit with a message. I purposely did not want to force a specific thumbnail view here.
- Taking advantage of Don's new parameter for SC SaveThumb for 'Zoom to Fill'.
Subfolders-noZoomtoFill_02.JPG
Subfolders-noZoomtoFill_02.JPG (65.03 KiB) Viewed 1497 times
Subfolders-withZoomtoFill_02.JPG
Subfolders-withZoomtoFill_02.JPG (84.07 KiB) Viewed 1497 times

Code: Select all

/*** - This script will generate thumbnails for all your subfolders (not files) under the current folder in a Zoom to Fill mode.
	  - It randomly selects a image in each subfolder.
	  	 The new thumbnails will be called folder.jpg. Any existing folder.jpg files will be renamed not deleted.
	  - The size of the thumbnail for the subfolders will be auto detected based on thumbnail size assigned for 
		 the current folder times a multiple 4 (default), though the multiple can be "1" (see $multiple below).
	  - First, go to the main folder where you have subfolders under it (e.g., G:\Wallpaper or H:\Photos).
	  - Ensure the view is a thumbnail viewing mode more than likely you would be or should be via a Folder View Settings or tab.
	  - If not in a thumbnail mode the script will exit with a message. I purposely did not want to force a specific thumbnail view here.
	  - By klownboy Feb 27, 2016...taking advantage of Don's new parameter for SC SaveThumb for 'Zoom to Fill'.
*/

    $multiple = "4";   //multiplication factor of thumbnail size you can change this if you like even make it "1"
    $T_sm = getkey("Width", "Thumbs") . "x" . getkey("Height", "Thumbs");
    $T_med = getkey("Width1", "Thumbs") . "x" . getkey("Height1", "Thumbs");
    $T_lg = getkey("Width2", "Thumbs") . "x" . getkey("Height2", "Thumbs");
	 $Tile_sm = getkey("TilesSmallSize", "Thumbs") . "x" . getkey("TilesSmallSize", "Thumbs");
	 $Tile_lg = getkey("TilesLargeSize", "Thumbs") . "x" . getkey("TilesLargeSize", "Thumbs");
    $T_Det = $T_sm; $T_Det_cap = "Details with Thumbnails #1" . " ($T_sm)";

   $views = <<<VIEWS
0|Details
1|Details with Thumbnails #1 ($T_sm)
2|List
3|Small Icons
4|Thumbnails #1 ($T_sm)
5|Thumbnails #2 ($T_med)
6|Thumbnails #3 ($T_lg)
7|Large Icons
8|Small Tiles ($Tile_sm)
9|Large Tiles ($Tile_lg)
VIEWS;

   $view = Get('View');
   $viewdata = FormatList($views, 'f', "<crlf>", $view . '|*');     // Get current view data line. 
   $cur_view = GetToken($viewdata, 2, '|', 't', 2);
	$thumbsize = gettoken(gettoken($cur_view, "1", ")", "t"), "2","(", "t");
	$thumbsize_X = gettoken($thumbsize, "1", "x", "t");$thumbsize_X = $thumbsize_X * $multiple;
	$thumbsize_Y = gettoken($thumbsize, "2", "x", "t");$thumbsize_Y = $thumbsize_Y * $multiple;

	if("|1|4|5|6|8|9|" UnLikeI "*|$view|*") {
		msg "Present view [$cur_view] is not a thumbnail or tile viewing mode."; end(1);} // You should have a FVS/tab setting in thumbnail mode
	else {
   	if (confirm(quote("OK") . "  to continue and generate thumbnails, [($thumbsize) x $multiple (multiple)] <crlf>           for each subfolder (not files) under the current folder.<crlf 2>" . quote("CANCEL") . " quit and/or select a different folder.")) {continue;} else {end(1);}
	}

  $all_sub_folders = FolderReport("dirs", "r", <curpath>, "r", , "|");
   foreach ($sub_folder,  $all_sub_folders, "|") {
      $images = formatlist(folderreport("files", "r", $sub_folder, , , "|"), "f", "|", "*.jpeg|*.jpg|*.png"); 
		$images = formatlist($images, "f", "|", "!*folder*"); 
		$random_image_no = rand("1",gettoken($images, "count", "|"));
		$sel_image = gettoken($images, $random_image_no, "|");
		if(exists("$sub_folder" . "\" . "folder.jpg") == "1") {
			renameitem("folder_old", "$sub_folder" . "\" . "folder.jpg", 0, "-01");}
      savethumb($sel_image, "folder", $thumbsize_X, $thumbsize_Y, "jpg", , 2);
  }
  #501;     //rebuild thumbnails in the current folder so you can see the result of the new subfolder thumbnails
I hope you enjoy it. Thanks.
Ken
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Post Reply