执行后重命名批处理文件扩展名
我想知道是否有办法在执行后更改批处理文件(.bat)的文件扩展名。例如,我想执行 abc.bat。批处理文件执行其应做的操作后,它通过将 .bat 更改为 .txt 来重命名自己,这可能吗?
I was wondering if there is a way to change the file extension of a batch file(.bat) after it's execution. So, for example, I want to execute abc.bat. After the batch file does what it's supposed to do, it renames itself by changing the .bat to .txt Would this be possible??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚尝试过。这很简单。在批处理文件的末尾,添加:
其中,
%~dp0
表示批处理文件的路径,正如我提到的此处。请注意,它必须是执行批处理文件的最后一步。
I just tried. It's pretty simple. At the end of your batch file, add:
In this,
%~dp0
indicates the path to your batch file as I mentioned here.Note it has to be the very last step of execution of the batch file.