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

Directory manipulation as part of an Extend Script

New Here ,
Nov 23, 2015 Nov 23, 2015

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

5.0K

Translate

Translate

Report

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
Enthusiast ,
Nov 23, 2015 Nov 23, 2015

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
New Here ,
Sep 26, 2020 Sep 26, 2020

Copy link to clipboard

Copied

Hi Sir Not Delete folder incude file

Votes

Translate

Translate

Report

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
Enthusiast ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

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