windows - How can I rename file extensions to another extension type, on another directory?
问题描述
I'm attempting to rename all files with the file extension of ".ACH" to ".TXT" on another directory.
I used the below batch file on my local machine and it works like a charm:
@Echo Off
CD C:\Users\jonsmith\OneDrive\PC\jonsmith-PC\Desktop\TestingBatch Rename
forfiles /S /M *.ACH /C "cmd /c rename @file @fname.TXT"
However, when I attempt to use the same syntax on the server, nothing happens:
@Echo Off
CD D:\AP\ACHTest Rename
forfiles /S /M *.ACH /C "cmd /c rename @file @fname.TXT"
I'm not understanding what I'm doing wrong, but something tells me it's how I'm using the CD
command.
解决方案
我不想强制批处理,所以我有一个更简单的方法。在 file1.ach 中:
Hello
在file2.ach里面:
Hi
代码:
del file1.ach
del file2.ach
当前目录:
echo Hello >>file1.txt
echo Hi >>file2.txt
不同的目录:
echo Hello >>D:\MyWork\TestRename\file1.txt
echo Hi >>D:\MyWork\TestRename\file2.txt
很简单,不用强求。
推荐阅读
- javascript - 用于显示/隐藏 div 的 jQuery SetTimeout 不起作用
- angular - 将 Angular 动画应用于生成的树节点
- angular - 在 Angular 12 (Karma 6.3.4) 中更新网络工作者的初始化语法后无法运行测试
- tensorflow - ValueError: 层 lstm 的输入 0 与层不兼容:预期 ndim=3,发现 ndim=4。收到的完整形状:(无、32、24、7)
- c# - 如何使用图片选择制作导航栏下拉菜单
- google-apps-script - 开始编辑宏在谷歌表单响应选项卡上工作
- sql - SQL - 将单个值应用于表中的所有行
- deployment - 如何部署 Api Platform 项目并访问 swagger / open API 接口
- java - 当我向其添加查询时,addListenerForSingleValueEvent 返回 dataSnapshot 值 null
- swiftui - 与 NSViewRepresentable 托管的 NSScrollView 绑定的问题