nSlashes = CountChars(WScript.Arguments(1), '/', true) - 2;
cmdLine = "\"" + WScript.Arguments(0) + "\"" + " -r -nH --cut-dirs=" + nSlashes + " -P " + 
	WScript.Arguments(2) + " " + WScript.Arguments(1);
//WScript.echo('Command:' + cmdLine);
var WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run(cmdLine, WScript.Arguments(3) == 0? 0 : 1, true);

function CountChars(sString, cChar, bIgnoreLast)
{
	nCount = 0, nLen = sString.length;
	if (bIgnoreLast && cChar == sString.charAt(nLen - 1)) nLen--;
	for (i = 0; i < nLen; i++) if (cChar == sString.charAt(i)) nCount++;
	return nCount;
}
