Hi John, here is the function that can convert everything in a particular folder:
code:
function ConvertFolder( FolderName, FileExtensionToLoad )
{
// Convert all files within a given folder, that have the given file extension.
// For example, convert all .3dm files inside of the folder c:\test :
// ConvertFolder( 'c:\\test', '3dm' );
// Create the FileSystemObject to get access to files and folders.
var FSO = new ActiveXObject( 'Scripting.FileSystemObject' );
var Files = FSO.GetFolder( FolderName ).Files;
// Go through every file in the folder.
for ( var FilesEnum = new Enumerator(Files); !FilesEnum.atEnd(); FilesEnum.moveNext() )
{
var File = FilesEnum.item();
var FileName = File.Path;
var FileExtension = FSO.GetExtensionName( FileName );
// If the extension matches the kind we are converting, call Convert() on it.
if ( FileExtensionToLoad.toLowerCase() == FileExtension.toLowerCase() )
Convert( FileName )
}
}
That goes just below the Convert() function, it will call the Convert() function for each matching file that it finds within that folder.
I've also attached an updated version of the BatchConvert.zip file that has the scripts all together in them.
Note - one thing that is easy to get messed up on is that in JavaScript code, the \ character starts an escape sequence which is how you represent certain special characters like return is \r etc... So when you want an actual \ character in a string you have to put in 2 of them, so make sure your file and folder names look like this: 'c:\\test\\folder' when they are in the script code.
- Michael
|