本帖最后由 WHY 于 2019-9-28 16:33 编辑
Test.ps1- $str = @'
- <!DOCTYPE html>
- <head>
- <meta name="viewport" content="initial-scale=1.0">
- <meta property="og:title" content="MyPhotoFolder"/>
- <meta charset="GB2312">
- <meta name="keywords" content="">
- <title>MyPhotoFolder</title>
- <link rel="stylesheet" href="../res/common.css?v=1.6.3">
- </head>
- <body>
- <div id="carousel" class="carousel full-page"><div id="pictures"></div></div>
- <div id="thumbnailCollapse" class="left-bottom">
- <div id="thumbIcons">
- <div class="showThumbs"></div><div class="showThumbs"></div><div class="showThumbs"></div>
- </div>
- </div>
- <div class="thumbs left-bottom">
- <div class="thumbs-nav">
- <div id="prevThumbs" class="icon-prev hidden"></div>
- <div id="nextThumbs" class="icon-next hidden"></div>
- </div>
- <div id="thumbs" style="left: 0px">
- <img src="1.png" data-href="1.png" alt="Photo-1">
- </div>
- </div>
- <div id="navigation" class="right-top">
- <nav>
- <a id="prev" class="icon-prev" title="Previous Image"> </a>
- <a id="next" class="icon-next" title="Next Image"> </a>
- </nav>
- <div id="fullscreen"><div id="fullscreenLogo" title="Go Fullscreen"></div></div>
- <div id="slideshow"><div id="slideshowIcon" ></div></div>
- </div>
- <div id="imageInfo" class="right-bottom"><h2 id="imageCount"></h2></div>
- <div id="sidebar" class="left-top">
- <div id="folders">
- <h2><a href="../index.html" class="folderTitle" style="margin-left:16px;" data-folderLevel="1">Home</a></h2>
- <h3><a class="folderTitle" style="margin-left:15px;" data-folderLevel="1">MyPhotoFolder</a></h3>
- <div id="links" class="left-bottom">
- <div class="sharing">
- </div>
- <script>window.jQuery || document.write('<script src="../res/jquery-1.10.2.min.js"><\/script>');</script>
- <script src="../res/main.js"></script>
- <script src="../res/jquery.touchSwipe.min.js"></script>
- <script>
- // Fully version: 1.6.3
- if( $("html").hasClass("ie8") || $("html").hasClass("ie7") ) {
- document.open();document.body.innerHTML = '';document.write(html); document.close();
- }else {
- $(window).load(function(){
- initSkin({
- animationInterval: 1000,
- amountImages: 4,
- wrapAround: true,
- fontSize: 13,
- showPhotoDataFromStart: false,
- slideshowInterval: 3,
- opacity: 30,
- });
- });
- }
- </script>
- </body></html>
- '@
- dir . -Include *.jpg, *.png, *.bmp -Recurse|?{$_ -is [IO.FileInfo] -and $_.Directory.Name -ne 'Res'}|group DirectoryName|forEach{
- $n = 0;
- $a = $_.Group | forEach{ '<img src="' + $_.Name + '" data-href="' + $_.Name + '" alt="Photo-'+ ++$n + '">' };
- $s = $str -replace 'MyPhotoFolder', [IO.Path]::GetFileName($_.Name);
- $s = $s -replace '<img src=.*>', ($a -join '');
- $s = $s -replace '(?<=amountImages: )4', $_.Count;
- sc -Path ($_.Name + '\index.html') -Value $s;
- }
- echo 'Done';
- [Console]::ReadKey()
复制代码
|