0

I am completely new to this, but I am trying to create a .bat file that will allow me to rename a pair of files within a designated folder and move them into a subfolder. The part I am having trouble with is that I am wanting a prompt to come up to identify/select the files to be renamed and moved.

Example file names are:

A1234, A1235, A1236, B1234, B1235, B1236, etc.

Is there a way to bring up a prompt that allows the user to type the shared name (ex 1234)of the files and rename and move both files to the designated subfolder?

Any and all help would be appreciated!

4

2 回答 2

1

建议的方法

对于部分问题

part I am having trouble with is that I am wanting a prompt to come up to identify/select the files to be renamed and moved. Is there a way to bring up a prompt that allows the user to type the shared name (ex 1234)of the files and rename and move both files to the designated subfolder?

使用搜索操作wildcard,就像"?1234"上面突出显示的情况一样(应该对所有可接受和预期的模式进行概括,这"*1234*"是最通用的)

现在对搜索得到的结果做一个RENAME内部循环。For

正如您建议您是 Batch 的新手,以下教程将帮助您构建文件。寻找类似的元素VariablesFor Loop

批处理教程

于 2012-10-25T13:58:12.980 回答
1

干得好

@echo off
set /p file=Please type shared name: 
for %%a in (C:\Folder\?%file%.*) do (
move "%%a" subdir
ren "subdir\%%a" newname.*
)
于 2012-10-25T14:53:47.343 回答