0 votes

I can easily copy/move/delete a normal file in JScript, but I am not succeeding to copy a compressed file out of its container. Is it possible to use JScript to copy the contents from inside a compressed (.ZIP) file? Using FLP, as long as the file ends up in the file list window, I can copy where I wish. When I try to use a JScript file copy it into the same folder as the .ZIP file resides in, I get nothing, well not exactly nothing, they do show up in the file list window.

Below is a graphic displaying all the FLP settings I'm using.

I added a tracing text file to see what my script is doing. Here is an excerpt from the tracer file showing results from one .ZIP file:

strPath: \\The_Corsair\CorsairData\CorsairWIP\Subtitles\Backlash (1956).English.srt-600536.zip\
strPath exist? true
strFullPath: \\The_Corsair\CorsairData\CorsairWIP\Subtitles\Backlash (1956).English.srt-600536.zip\Backlash.1956.1080p.BluRay.x264-nikt0-English.srt
strFullPath exist? false
strFileName: Backlash.1956.1080p.BluRay.x264-nikt0-English.srt
strFileName exist? false
zipFile: Backlash (1956).English.srt-600536.zip

As you can see, even though FLP sends the file name to: "function isValidFileName( strPath, strFileName )" as strFileName, the JScript keeps reporting that neither it, nor strFullName (strPath + strFileName) exists.

I've read and re-read the FLP manual and found no answer to my dilemma. I've also scoured my JScript + VBScript manuals for a clue and found none there either. I'm thinking it is FLP specific that it even finds a name to pass to the script.

I've also included my script (below) with complete commenting to see if I missed something important.

//		zippedSRTcopyOut.js
//	Main fileName = \.srt$  -  Main search type = RegEx
//	Look in: \\The_Corsair\CorsairData\CorsairWIP\Subtitles
//	Compressed files = *.ZIP

var zipObjFSO = new ActiveXObject("Scripting.FileSystemObject");
var RootDir ="\\\\The_Corsair\\CorsairData\\CorsairWIP\\"

	var tracer;
	traceExt = ".txt"
	var traceFile = "Post_ZippedSRT.tracer";
	traceFile += traceExt;						// Name of tracing file
	var bugSpray = RootDir + traceFile;			// Full path of tracing file
	var SubsDir = RootDir + "Subtitles" + "\\"; // Where to find zipped up subtitles
    var	subsDirLeng = SubsDir.length;			// Length of SubsDir (for parsing strPath)

	if (!zipObjFSO.FileExists(bugSpray))
		zipObjFSO.CreateTextFile(bugSpray, true);	// If bugSpray doesn't exist, create it
 	tracer = zipObjFSO.OpenTextFile(bugSpray, 2);	//	Open bugSpray in over-write mode
		tracer.WriteLine("		Tracer file name: " + traceFile);
		tracer.WriteLine("		Subtitles folder: " + SubsDir);	// Write Zipped Subtitles folder name to bugSpray
	tracer.close();

function isValidFileName( strPath, strFileName )
{	//  BEGIN : function isFileNameValid
	var bSPath = false;		// boolean strPath
	var bSFile = false;		// boolean strFileName
	var bFullP = false;		// boolean strFullPath
    var zipFile = "";		// Parse .zip folder from strPath
	var copySRT = "";		// FSO name for extracting .srt file from .ZIP file
    var	strPathLeng = -1;	// Length of strPath, used for parsing
    var strFullPath = strPath + strFileName;	// full path name of found .srt file

    try
    {
        bSPath = zipObjFSO.FileExists(strPath);
    	if (!bSPath) 		// Verify existence of strPath before moving on
    		return bSPath;
        bSFile = zipObjFSO.FileExists(strFileName);		// Boolean for strFileName existence
        bFullP = zipObjFSO.FileExists(strFullPath);		// Boolean for strFullPath existence
    	strPathLeng = strPath.length;					// Length of strPath, used for parsing
		zipFile = strPath.substr(subsDirLeng, strPathLeng-subsDirLeng-1);// Isolate the zipFile from path string, drop last \

	 	tracer = zipObjFSO.OpenTextFile(bugSpray, 8);	// Open bugSpray in append mode
			tracer.WriteLine();
			tracer.WriteLine("	Local Values");			// Values that change for each pass, write to tracing file
			tracer.WriteLine("strPath: " + strPath);			// The dir path to the .srt file (.ZIP file)
			tracer.WriteLine("strPath exist? " + bSPath);		// Does the .ZIP file (full dir path) actually exist?
			tracer.WriteLine("strFullPath: " + strFullPath);	// Entire path, including the .srt file name
			tracer.WriteLine("strFullPath exist? " + bFullP);	// Does entire path actually exist?
			tracer.WriteLine("strFileName: " + strFileName);	// Name of the .srt file within the .ZIP file
			tracer.WriteLine("strFileName exist? " + bSFile);	// Does the .srt file actually exist?
			tracer.WriteLine("zipFile: " + zipFile);			// The .ZIP file containing the .srt file
			tracer.WriteLine("------------ End of Pass -------------");
		tracer.close();

		copySRT = objFSO.GetFile(strFileName);	//	!!!FAILED!!!
		copySRT.CopyFile(subsDir, false);	// Copy .srt from .ZIP file to Subtitles folder with new name !!!FAILED!!!

	}

    catch( e )
    {	// caught error
    	bSPath = false;
    }	//search failed

    return bSPath;
}

Am I asking for more than FLP is capable of doing?

Thank you for your time and effort,
Mike

by (225 points)

1 Answer

0 votes

The path provided to isValidFileName is a virtual path, ie it doesn't exist as an actual file on the file system, only the parent .zip does.

You would need some sort of command line utility to extract the file for you to a location. 7zip might be able to do that.

If you have C# experience, you could use the FileLocator Pro search engine within code. The SearchResultItem class has a method, CopyFileTo, which would do what you want.

To run a command in JScript use the shell object, e.g.

var objShell = new ActiveXObject("WScript.Shell");
objShell.run("Notepad.exe");
by (34.6k points)
Added information on how to run an external command.
...