#2 Du har lagt spørgsmålet under "Programmering", så derfor troede jeg at du ville lære det. ;-)
Eksperten har også en kategori "Opgaver" hvis man gerne vil have andre til at lave det.
Nå, men nu har jeg tastet i 3 timer, og har fået banket et script sammen.
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="
http://www.w3.org/1999/xhtml"><hta:application id="oHTA" applicationname="MyHTA">
<head>
<title>File Search</title>
<style type="text/css">
body {background-color: white; font-family : sans-serif;}
</style>
<script type="text/javascript">
var oFSO = new ActiveXObject("Scripting.FileSystemObject");
var CANCEL;
var searchWords;
var searchWordCount;
var subDirArray = [];
var count;
var fcount;
var found;
var ResultTable;
function StartSearch() {
ResultTable=document.getElementById("resultTable");
while ( ResultTable.hasChildNodes() ) ResultTable.removeChild(ResultTable.lastChild);
CANCEL = false;
document.getElementById("startButton").disabled = true;
document.body.style.cursor = "wait";
searchWords = document.frmSearch.name.value.split(',');
searchWordCount = searchWords.length;
for (var i=0; i < searchWordCount; i++) {
searchWords[i] = searchWords[i].replace(/ /g,'');
}
subDirArray = [];
subDirArray[0] = document.frmSearch.infolder.value;
count = 0;
fcount = 0;
found = 0;
SearchFolder();
}
function SearchFolder() {
if (count == subDirArray.length || CANCEL) {
document.getElementById("statusDiv").firstChild.nodeValue = ' ' + found + ' files found. ' + fcount + ' files searched in ' + count + ' directories.';
document.getElementById("startButton").disabled = false;
document.body.style.cursor = "";
return;
}
document.getElementById("statusDiv").firstChild.nodeValue = subDirArray[count];
var objDir = oFSO.GetFolder(subDirArray[count]);
aFolders = new Enumerator(objDir.SubFolders);
for (var i=0;!aFolders.atEnd();aFolders.moveNext()) {
subDirArray[ subDirArray.length ] = aFolders.item().Path;
}
aFiles = new Enumerator(objDir.Files);
for (var i=0;!aFiles.atEnd();aFiles.moveNext()) {
SearchFile( aFiles.item() );
}
count++;
setTimeout( 'SearchFolder()', 1 );
}
function SearchFile( file ) {
fcount++;
for (var i=0; i < searchWordCount; i++) {
if (file.Name.indexOf( searchWords[i] ) > -1 ) {
found++;
var link = document.createElement("a");
var row = document.createElement("tr");
var cell1 = document.createElement("td");
var cell2 = document.createElement("td");
var fileDate = new Date(file.DateCreated );
var MM = (fileDate.getMonth() + 1).toString();
if (MM.length < 2) MM = '0' + MM;
link.href = file.Path;
link.title = file.Path;
link.appendChild( document.createTextNode( file.Name + ' ') );
cell1.appendChild( link );
cell2.appendChild( document.createTextNode( ' ' + document.frmSearch.outfolder.value + '\\' + fileDate.getFullYear() + '_' + MM ) );
row.appendChild( cell1 );
row.appendChild( cell2);
document.getElementById( "resultTable" ).appendChild( row );
return;
}
}
}
function moveFiles(mType) {
document.body.style.cursor = "wait";
document.getElementById("startButton").disabled = true;
setTimeout("doMoveFiles('" + mType + "')", 5);
}
function doMoveFiles(mType) {
var fileTRs = document.getElementById("resultTable").getElementsByTagName("TR");
for (var i = 0; i < fileTRs.length && CANCEL == false; i++) {
var nextFile = oFSO.getFile(fileTRs[i].getElementsByTagName("A")[0].href);
var toFolderName = fileTRs[i].getElementsByTagName("TD")[1].firstChild.nodeValue.replace(/\\/g, "/").replace(/ /g, "");
var toFolder = oFSO.GetFolder(document.frmSearch.outfolder.value);
//alert("#" + toFolderName + "#\n" + oFSO.folderExists(toFolderName));
if (!oFSO.folderExists(toFolderName)) {
oFSO.CreateFolder(toFolderName);
}
if (mType == "MOVE") {
nextFile.move(toFolderName + '/' + nextFile.Name);
}
if (mType == "COPY") {
nextFile.copy(toFolderName + '/' + nextFile.Name);
}
}
document.getElementById("startButton").disabled = false;
document.body.style.cursor = "";
}
</script>
</head>
<body>
<form name="frmSearch">
<table>
<thead><tr>
<th>File types</th>
<th>From Folder</th>
<th>To Folder</th>
</tr></thead><tbody><tr>
<td><input type="text" name="name" value=".wmv, .mov, .mp4" size="30" title="List of search texts" ></td>
<td><input type="text" name="infolder" value="C:\VideoUploads" size="40" title="Folder to search" ></td>
<td><input type="text" name="outfolder" value="C:\VideoArchive" size="40" title="Folder to search" ></td>
</tr><tr>
<td></td>
<td><input type="button" id="startButton" value="Search Folder" onclick="StartSearch();"></td>
<td><input type="button" value="Cancel" onclick="CANCEL=true;"></td>
</tr></tbody>
</table>
</form>
<div id="statusDiv"> </div>
<div id="buttonsDiv">
<input type="button" value="Move" onclick="moveFiles('MOVE')" >
<input type="button" value="Copy" onclick="moveFiles('COPY')" >
</div>
<p>
<table border="0">
<thead><tr><th>File</th><th>To Folder</th></tr></thead>
<tbody id="resultTable"></tbody>
</table>
</p>
</body>
</html>