简体   繁体   中英

How to create a folder in Spotfire Library using IronPython script

I want to create a folder in Spotfire Library and save the analysis file using an IronPython script. But I'm not sure how to pass LibraryItem in the create folder function of Library Manager.

You need to use the LibraryManager.TryGetItem method to select the parent folder and then pass that and the new folder name to the LibraryManager.CreateFolder method.

This worked for me: -

# Import namespaces
from Spotfire.Dxp.Framework.Library import *

libraryManager = Document.GetService(LibraryManager)
parentFolder = '/path/parentFolder/'
newSubFolder = 'newSub'

parentFolderExists, folder = libraryManager.TryGetItem(parentFolder, LibraryItemType.Folder)
if parentFolderExists:
    subfolderExists, subfolder = libraryManager.TryGetItem(customer + newSubFolder + '/', LibraryItemType.Folder)
    if not subfolderExists:
        print customer
        libraryManager.CreateFolder(folder, newSubFolder, LibraryItemMetadataSettings())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM