copy upload rules from one project/server to another one or add many rules from a text file

Hello,

I want to add upload rules on a new project that has to be setup on a new server. There are no upload rules existing at the moment.

1. Is there a way to export the upload rules from another server and then import on the the server?

2. If 1. is not possible, I want to add the rules from an excel or txt file instead of clicking 1000 times in the admin console.

I found Any Command line support Upload Rules ? - Dimensions CM User Discussions - OpenText Dimensions CM (microfocus.com) as answer from  

and tried this.

I copied this text block and added some line breaks:

importPackage(Packages.com.serena.dmclient.api)
try { //////////// Change these two up to your Product configuration:
var uploadEnvName = "Project Merge Tool;mrg";
var projName = "$GENERIC:TEST;mrg-123456"; // Replace "$24" with just "$" when you're taking this ID from Browser ///////////////////////////////////////////////////////////////
var db = defaultDatabase;
var env = db.uploadEnvironments.get(uploadEnvName);
if (env == null) throw ("Upload Environment '" uploadEnvName "' does not exist.");
var projs = env.projects;
var proj = projs.get(projName);
try { //Define a new inclusion rule variable
var fileNamePattern = "**/*.ext3\n**/*.ext4";
var dataFormat = "HTML";
var itemType = "SRC";
var designPart = "";
var seq = 2;
var exclusion = "**/Debug/*.*\n**/Release/*.*";
var incDetails =
new UploadInclusionDetails(fileNamePattern, dataFormat, itemType, designPart, exclusion); incDetails.seqNo = seq;
var incs = proj.inclusions; // Create a new upload inclusion rule inc = incs.add(incDetails);
print("Rule is added fine: " inc); } catch(e) { print(e) } } catch (e) { print(e) } finally { }

...into a file called AddRule.js and changed the var projName = "$GENERIC:QLARIUS;mrg-4213926" to "$GENERIC:TEST;mrg-123456" , the var uploadEnvName = "Project Merge Tool;mrg" seems to be the same in my project.

I ran the for a test the command dmpmcli -user admin -pass admPa$$word -dbname cm_typical -host DimCM-hostname -dsn dim15 -file C:\UploadRules\AddRule.js (adapted with my content , -host = server , -dbname = DB Name , -dsn = DB connection from the dimensions desktop login )

...but it just told me:

js: "C:\temp\AddRule.js", line 7: missing ) in parenthetical
js: if (env == null) throw ("Upload Environment '" uploadEnvName "' does not exist.");
js: ............................................................^
js: "C:\temp\AddRule.js", line 20: missing ) after argument list
js: print("Rule is added fine: " inc); } catch(e) { print(e) } } catch (e) { print(e) } finally { }
js: ................................^
js: "C:\temp\AddRule.js", line 1: Compilation produced 2 syntax errors.
js: Compilation produced 2 syntax errors.

I have no idea, what is wrong.

And even if this will work, I have no idea, how to add another 100 upload rules in this code. I think it would be better to have not all these variable definitions and instead put directly all needed info in one single command line? This Line I could duplicate with excel for every new upload rule - would this be possible?