Blakeseven
Technical User
I have a large dir tree I need to work thru. I have set up this script to look in each sub dir and find *.tif files then use a program called tiff junction to turn them into pdf's. the problem I have is striping the "f:\" out of a var so I can build the same dir tree in a different drive. can any one help
Ben
fso = new ActiveXObject( "Scripting.FileSystemObject" );
var startDir = "f:\\";// Hard coded for simplicity
var WshShell = WScript.CreateObject("WScript.Shell"
function main()
{
strip( startDir );
}
main();
function scandir( dir,ben )
{
// Get Current Folder
var srcFolder = fso.GetFolder( dir );
// Get any sub folders to current directory
var esub = new Enumerator( srcFolder.SubFolders );
// Loop through sub folder list and scan
// through a recursive call to this function
for(; !esub.atEnd(); esub.moveNext() )
{
var f = fso.GetFolder( esub.item() );
var srcFolder = fso.GetFolder( dir );
sub= esub.item().Name; // Don't need this : + "\n";
//WScript.Echo ("f="+f);
//var tom=f;
//var ben = tom.substr(3);
cmd='"'+'C:\\Program Files\\Aquaforest\\TIFF Junction\\bin\\tiffjunction.exe'+'"'+' -P -T '+'"'+'f:\\pdf'+ben+'\\'+sub+'.pdf'+'"'+' "'+f+'\\*.tif'+'"';
WScript.Echo(cmd);
WshShell.Run(cmd,1,true);
// WScript.Echo('"'+f+"\00000001.pdf"+'"',"f:\\pdf\\"+sub+".pdf"
strip( f );
}
}
function strip( srt )
{
var ben=srt.substr(3);
scandir (srt,ben);
}
Ben
fso = new ActiveXObject( "Scripting.FileSystemObject" );
var startDir = "f:\\";// Hard coded for simplicity
var WshShell = WScript.CreateObject("WScript.Shell"
function main()
{
strip( startDir );
}
main();
function scandir( dir,ben )
{
// Get Current Folder
var srcFolder = fso.GetFolder( dir );
// Get any sub folders to current directory
var esub = new Enumerator( srcFolder.SubFolders );
// Loop through sub folder list and scan
// through a recursive call to this function
for(; !esub.atEnd(); esub.moveNext() )
{
var f = fso.GetFolder( esub.item() );
var srcFolder = fso.GetFolder( dir );
sub= esub.item().Name; // Don't need this : + "\n";
//WScript.Echo ("f="+f);
//var tom=f;
//var ben = tom.substr(3);
cmd='"'+'C:\\Program Files\\Aquaforest\\TIFF Junction\\bin\\tiffjunction.exe'+'"'+' -P -T '+'"'+'f:\\pdf'+ben+'\\'+sub+'.pdf'+'"'+' "'+f+'\\*.tif'+'"';
WScript.Echo(cmd);
WshShell.Run(cmd,1,true);
// WScript.Echo('"'+f+"\00000001.pdf"+'"',"f:\\pdf\\"+sub+".pdf"
strip( f );
}
}
function strip( srt )
{
var ben=srt.substr(3);
scandir (srt,ben);
}