Welcome To Support Community

Materials Studio

Advanced Search
Ask Search:
José LimaJosé Lima 

script for export files

Hi everyone!

I would like to know if exist a way to export many ".xsd" files, at the same folder, as ".mol" files at another folder in MS.. maybe a script to do that with a loop for each xsd files... 

Thaks for your help.

 
Best Answer chosen by José Lima
reinierreinier
Hi José,

The documentation on the Import function in scripting has a snippet showing how to import documents in a given folder (outside the project):

opendir my $folder, $folderPath or die "Couldn't open folder";
my @allfiles = sort {lc $a cmp lc $b} grep !/^\.\.?$/, readdir $folder;
foreach my $file (@allfiles) {
    my $doc = Documents->Import($folderPath.$file);
    $doc->Close;
}
You could insert an Export statement to save as  .mol in another folder:
$doc->Export($folderPath2 . $doc->Name . ".mol");
 
Alternatively, to export all structure documents in a project you could iterate over the Documents hash:
foreach my $key (keys %Documents) {
    my $doc = $Documents{$key};
    next if $doc->Type ne "3DAtomistic";
    $doc->Export($folderPath2 . $doc->Name . ".mol");
    $doc->Close;
}
 
Good luck,
Reinier