Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to create a folder?

Community Expert ,
Jun 19, 2021 Jun 19, 2021

Coming along a problem I wrote this simple test:

#target framemaker
var backupFolder;
  backupFolder = new Folder ("E:\\_DDDprojects\\FM-JsxLib\\Docu" + "\\_Backups1");
  backupFolder = new Folder ("/e/DDDprojects/FM-JsxLib/Docu" + "/_Backups2");

Running in ESTK with an FM document open:

Selected target is ESTK CC :

   Result: /e/DDDprojects/FM-JsxLib/Docu/_Backups1
   Result: /e/DDDprojects/FM-JsxLib/Docu/_Backups2

Selected target is FrameMaker 15

   Result: /e/DDDprojects/FM-JsxLib/Docu/_Backups2

In both scenarios no folder is created!

I do not get an error from the New command (backupFolder.error is a blank string)

TOPICS
Scripting
365
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Jun 19, 2021 Jun 19, 2021

Hi Klaus,

you have only created a Folder object, but not a folder.

To create the folder:

if (!backupFolder.exists){backupFolder.create()}

Have a nice day

 

Translate
Enthusiast ,
Jun 19, 2021 Jun 19, 2021

Hi Klaus,

you have only created a Folder object, but not a folder.

To create the folder:

if (!backupFolder.exists){backupFolder.create()}

Have a nice day

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2021 Jun 19, 2021

Thanks, Klaus, for this enlightment!

But, why does Rick's code (part of the event script here only) work?

CP_BA.backupOnSave = function (sparam) {	
  var backupFolder, file;
  backupFolder = new Folder ("C:\\DATA\\Scripts\\_Backups"); // Target folder for backups.
  file = new File (sparam);                     // Make a file object for the document that was just saved.
  file.copy (new File (backupFolder + "\\" + file.name)); // Copy the file to the backup folder.
};

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2021 Jun 19, 2021
LATEST

Hi Klaus,

I will have to look at my code, but I may have made the assumption that the folder already exists.

Rick

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines