如何从Ant中的目录名称获取文件名?

时间:2023-01-27 10:57:43

I have a DirSet which I would like to convert to a comma-delimited list of directory names. I'm not interested in the full path, just the names. Using the ant-contrib "for" task I've been able to iterate the directories and create the target list, but for the life of me I can't figure out how to extract just the directory name from the full path.

我有一个DirSet,我想将其转换为以逗号分隔的目录名列表。我对完整的路径感兴趣,只是名字。使用ant-contrib“for”任务我已经能够迭代目录并创建目标列表,但对于我的生活,我无法弄清楚如何从完整路径中提取目录名称。

Is there an Ant task that helps with concatenating/extracting path parts (like File in Java, or System.IO.Path in .NET)?

是否有一个Ant任务有助于连接/提取路径部分(如Java中的File或.NET中的System.IO.Path)?

2 个解决方案

#1


I think you are looking for the Dirname task.

我认为你正在寻找Dirname任务。

#2


I would use propertyregex from ant-contrib:

我会使用来自ant-contrib的propertyregex:

http://ant-contrib.sourceforge.net/tasks/tasks/propertyregex.html

Regards.

#1


I think you are looking for the Dirname task.

我认为你正在寻找Dirname任务。

#2


I would use propertyregex from ant-contrib:

我会使用来自ant-contrib的propertyregex:

http://ant-contrib.sourceforge.net/tasks/tasks/propertyregex.html

Regards.