FCLT#64645 Herstelscript voor thumbnail foto's

svn path=/Customer/; revision=48710
This commit is contained in:
Erik Groener
2020-11-04 14:01:30 +00:00
parent befe913211
commit 7133b855fb

View File

@@ -1,59 +1,66 @@
// FCLT#64524
WScript.Echo("// scriptfile: FCLT#64524.js");
WScript.Echo("// Create missing thumbnails in SML-path");
WScript.Echo("// Starting at " + new Date());
if (!WScript.Arguments.length)
WScript.Echo("// Herstelscript voor thumbnail foto's. Voegt ontbrekende thumbnails toe.");
WScript.Echo("// Parameters: Pad vanaf waar gezocht moet worden.");
WScript.Echo("// Naam van map waarin de originele afbeeldingen staan.");
WScript.Echo("// Gestart op " + new Date());
// Voorbeeld:
// cscript -e:javascript fclt#64524.js w:\branch20202\CUST\MDUX\photos\INS INSDEEL
//
// Beginnend in pad "w:\branch20202\CUST\MDUX\photos\INS" wordt recursief gezocht naar de map "INSDEEL"
// waarin de originele afbeeldingen staan.
// In de map "w:\branch20202\CUST\MDUX\photos\INS\...\...\INSDEEL\thumb" wordt gekeken of er van de
// originele afbeelding een thumbnail bestaat. Zo niet dan wordt deze aangemaakt. Bestaat de "thumb"-map
// niet dan wordt deze ook aangemaakt.
if (WScript.Arguments.length < 2)
{
WScript.Echo("Missing custid");
WScript.Quit();
}
var CustId = WScript.Arguments(0);
WScript.Echo("// CustId=" + CustId);
WScript.Echo("//");
//var StartPath = "../Branch20202/CUST/" + CustId + "/flexfiles/prs";
var StartPath = "../FPlace5i/CUST/" + CustId + "/flexfiles/prs";
var count_picture = 0;
var count_resize = 0;
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FolderExists(StartPath))
{
var thisFolder = fso.GetFolder(StartPath);
LoopFolder(thisFolder);
WScript.Echo("Onvoldoende parameters meegegeven.");
}
else
{
WScript.Echo("No path: " + StartPath);
var StartPath = WScript.Arguments(0);
var OrgMap = WScript.Arguments(1);
WScript.Echo("// Start in: " + StartPath);
WScript.Echo("// Afbeeldingen in map: " + OrgMap);
WScript.Echo("//");
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FolderExists(StartPath))
{
var count_picture = 0;
var count_resize = 0;
var StartFolder = fso.GetFolder(StartPath);
LoopFolder(StartFolder, OrgMap);
WScript.Echo("//");
WScript.Echo("// Aantal afbeeldingen gevonden: " + count_picture);
WScript.Echo("// Aantal afbeeldingen verkleind: " + count_resize);
}
else
WScript.Echo("Onbekend pad: " + StartPath);
}
WScript.Echo("//");
WScript.Echo("// Pictures found: " + count_picture);
WScript.Echo("// Pictures resized: " + count_resize);
WScript.Echo("// Done at " + new Date());
WScript.Echo("// Klaar op " + new Date());
WScript.Quit(0);
function LoopFolder(path)
function LoopFolder(thisfolder, map)
{
var enumFolder = new Enumerator(path.SubFolders);
var enumFolder = new Enumerator(thisfolder.SubFolders);
for (; !enumFolder.atEnd(); enumFolder.moveNext())
{
var folder = enumFolder.item();
if (folder.name == "SML")
mapSML(folder);
var nextfolder = enumFolder.item();
if (nextfolder.name == map)
ResizeFolder(nextfolder);
else
LoopFolder(folder);
LoopFolder(nextfolder, map);
}
}
function mapSML(SmlPath)
function ResizeFolder(OrgPath)
{
WScript.Echo(SmlPath);
WScript.Echo(OrgPath);
var message = "";
var enumFile = new Enumerator(SmlPath.Files);
var enumFile = new Enumerator(OrgPath.Files);
for (; !enumFile.atEnd(); enumFile.moveNext())
{
var thisfile = enumFile.item();
@@ -61,12 +68,12 @@ function mapSML(SmlPath)
if (f.Name.match(/\.(png|jpg|jpeg)$/i))
{
count_picture ++;
var ThumbPath = SmlPath + "/thumb/";
var ThumbPath = OrgPath + "/thumb/";
if (!fso.FolderExists(ThumbPath))
fso.CreateFolder(ThumbPath);
if (!fso.FileExists(ThumbPath + f.Name))
resizeImage( {OrgPath: SmlPath, Name: f.Name} );
resizeImage( {OrgPath: OrgPath, Name: f.Name} );
}
}
}
@@ -84,7 +91,7 @@ function resizeImage(pic)
}
catch(e)
{
message = "Cannot load picture " + pic.OrgPath + "/" + pic.Name;
message = "Kan afbeelding niet vinden " + pic.OrgPath + "/" + pic.Name;
}
if (!message)