ImageJ宏代码更改目录。

[英]ImageJ macro code to change directory


I am learning how to write macros in ImageJ. I have the user select a folder where data is stored, e.g.,

我正在学习如何在ImageJ中编写宏。我让用户选择一个存储数据的文件夹,例如,

path=getDirectory("Choose a data folder");

Once the user has selected the folder, e.g.,

一旦用户选择了文件夹,例如,

path = D:\data_superfolder\data_folder

I then need to access a file that is up one level, e.g.,

然后我需要访问一个上一级的文件,例如,

newpath = D:\data_superfolder

In Matlab to move up one level all i need to do is,

在Matlab中,要提升一个级别,我需要做的就是,

cd('..')

which is super simple, but I've read through the ImageJ user manual I can't find similar code. How do I do this?

这非常简单,但我已经读过ImageJ用户手册,我找不到类似的代码。我该怎么做呢?

Thanks!

谢谢!

1 个解决方案

#1


2  

You can append /.. to a directory path to refer to its parent folder.

你可以添加/ . .指向目录路径以指向它的父文件夹。

Here is an example macro that prompts the user to choose a directory, then lists the contents of its parent.

下面是一个示例宏,它提示用户选择一个目录,然后列出其父目录的内容。

path = getDirectory("Choose a folder");
list = getFileList(path + "/..");
for (i = 0; i < list.length; i++) {
    print(list[i]);
}
智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2015/04/10/d8e265f47921fa499e8d6e0ac2764445.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告