0

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.

4

1 回答 1

-1

我不想强制批处理,所以我有一个更简单的方法。在 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

很简单,不用强求。

于 2021-07-07T13:07:03.317 回答