如何使用 Ant 重命名文件夹? [英] How to rename a folder using Ant?

查看:97
本文介绍了如何使用 Ant 重命名文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用时间戳重命名我的应用程序文件夹,然后使用相同的文件夹名称解压缩我的应用程序的较新版本.使用 Ant (move task),它看起来就像您可以将内容从一个文件夹移动到另一个文件夹一样.

I want to rename my application folder with a time stamp and then unzip a newer version of my app using the same folder name. Using the Ant (move task), it looks like you can move contents from one folder to another.

这是我在 Ant 中唯一能做到的方法吗?

Is this the only way I can do this in Ant?

推荐答案

移动任务确实可以满足您的需求,但命名有点混乱.如果你认为你的目录是 Java 意义上的文件"——一个文件是一个文件系统句柄,可以代表通常意义上的目录或文件——那么移动任务就有意义了.

The move task does do what you're after, but the naming is a bit confusing. If you consider your directory is a 'file' in the Java sense - a file being a filesystem handle that can represent, among others a directory or a file in the usual sense - then the move task makes sense.

所以下面

<move file="mySourceDirName" tofile="myTargetDirName"/>

表示重命名/移动目录mySourceDirName 改为myTargetDirName.

means rename/move the directorymySourceDirName to be instead myTargetDirName.

接下来是

<move file="mySourceDirName" todir="someExistingDir"/>

表示将目录mySourceDirName移动为现有someExistingDir目录的子目录.

means to move the directory mySourceDirName to become a child directory of the existing someExistingDir directory.

因此,在 ant 中,'file' 属性指的是有问题的目标,而 'todir' 属性指的是作为目标文件或目录的新父位置的目录.

So, in ant the 'file' attribute refers to the target in question, and the 'todir' attribute refers to the directory that is the new parent location for the target file or directory.

这篇关于如何使用 Ant 重命名文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆