Export Script to remove pList and add slash to file paths

I need to create an export script that will not include (or delete) the pList file and also add a forward slash to the javascript paths in the generated html file. For example:

<script type="text/javascript" src="networks.hyperesources/jquery.js"></script>


<script type="text/javascript" src="/networks.hyperesources/jquery.js"></script>

for all Javascript references in the html file including the main hype javascript file.

This seems like a case for the advanced export functionality. Can someone let me know if this is possible and point me in the right direction.

Thank you.

You don’t need a script to not include the restorable plist file.

In Hype, go to preferences -> General and uncheck Create restorable document file when exporting

Although an export script probably can be written to change the paths.

I figured it is just as easy to select the html file and run a Service on it.

Here is one I just knocked up.

The unzipped Service workflow needs to be placed in you user services folder.


You can then select a html file and use Services contextual menu -> Slash_To_JS_path

  • The automator workflow checks if the selected file is a html file.

  • This will look for all

javascript" src="
and replace it with

javascript" src="/

  • It then overwrites the file.

The workflow uses Javascript (JXA) along with bridged Objective - C to read and write the file.

( code signed)
Slash_To_JS_Path.workflow.zip (267.1 KB)

This is the basic code used in the workflow.

	//  Created by Mark Hunte on 10/02/2018.
//  Copyright © 2018 Mark Hunte. All rights reserved.

function run(input, parameters) {

var app = Application.currentApplication();
app.includeStandardAdditions = true;
var finder = Application('Finder');
var SystemEvents = Application('System Events');
fm = $.NSFileManager.defaultManager;

//-- We get the fist finder selection here as it is easier to use in jxa  from this than  the resulting selection from the workflow.
var htmlDoc = finder.selection()[0]
//-- we convert the files url to a string   ( will be a file path)
theFile  = htmlDoc.url().toString()

//-- we convert to OBJECTIVE - C URL
var filePath =  $.NSURL.URLWithString(theFile)

  //-- We check if the file is a html
 if (ObjC.unwrap(filePath.pathExtension) === "html" ){
 //-- Get the files contents  
txtFileContents = $.NSString.stringWithContentsOfFileEncodingError(filePath.path , $.NSUTF8StringEncoding , null)

//-- Replace all occurrences of String
myObject=  txtFileContents.stringByReplacingOccurrencesOfStringWithString('javascript" src="','javascript" src="/');

 //-- Create a string path 
 var thisFilePath = ObjC.unwrap(filePath.path) ;
 //-- overwrite the file
$.NSString.stringWithString(myObject).writeToFileAtomicallyEncodingError(thisFilePath,true,$.NSUTF8StringEncoding , null)