Skip to main content
EganSolo
Participant
Nov 24, 2015 1:40 AM UTC
Question

Directory manipulation as part of an Extend Script

Hello,

I am working through my first extend script.

FrameMaker 12

Windows 10

Given a specified path (say "C:\MyFiles\FM_Format") containing a list of *.fm files which belong to a frame maker book, I want to save a *.mif copy of these files into a different folder (C:\MyFiles\MIF_Format).

I've figured out how to iterate over an open book, open each file and how to save the file as an mif file.

What remains for me to do is

  1. Determine if the MIF_Format exists.

  2. If it does not then create it.

  3. Otherwise, clear all the files in that folder (delete them).

  I have seen another post indicating that I could write a batch file to perform these three tasks and then I could invoke this batch file from within the script, which is great. I was just curious to know if there were native functions that could perform the same?

Thanks for any feedback.

Egan.

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

Klaus Göbel
Legend
Nov 24, 2015 7:15 AM UTC

Hi Egan,

Dealing with files and folder is explained in the Javascript Tools Guide CC in Chapter 3 (File System Access).

You can find it in ESTK -> Help -> Javascript Tools Guide CC

Here is an example how you can delete files and folders:

Folder must be empty !!!

//delete file

var MyFile = new File ("C:\\deletetest\\test.txt");

if (MyFile.exists)

    {

        MyFile.remove();

     }

//delete folder - folder MUST be empty

var MyFolder = new Folder ("C:\\deletetest");

if (MyFolder.exists)

    {

        MyFolder.remove();

     }

Hope that helps.

Translate
Participant
Sep 26, 2020 5:40 PM UTC

Hi Sir Not Delete folder incude file

Translate
Klaus Göbel
Legend
Sep 28, 2020 6:34 AM UTC

To delete a folder + all files + all subfolders just have a look here:

https://community.adobe.com/t5/framemaker/afile-remove-not-working-as-expected/m-p/8143478?page=1

Translate