Windows 10命令行/脚本 - 用于或循环文件名(1),文件名(2)

时间:2016-08-11 16:50:33

标签: windows batch-file

我正在编写一个当前在Windows命令行运行的脚本(批处理文件)。任务是我在文件夹中有可变数量的文件。文件以filename(1),filename(2)等格式命名。

我正在尝试设置FOR循环或使用IF ... GOTO将文件名(1到9)移动到一个文件夹,然后将文件名(10到99)移动到另一个文件夹,依此类推,以便我可以处理它们分开。

因此,简单的方法是按顺序复制以将源文件连接到单个目标文件中。或者,一种为复制和/或移动命令构造文件名的方法,该命令按顺序查看诸如test(1),test(2),... test(9)之类的文件,然后停止。

文件按以下顺序在文件夹中排序 - test(1).txt test(2).txt test(3).txt test(4).txt test(5).txt test(6).txt test( 7).txt test(8).txt test(9).txt

但是,可能只有两个或三个文件,或者文件夹中可能有1000个文件需要处理。

我一直试图设置这样的东西:

set count1=9
set count2=99
set count_loop=1

:while_loop1
echo "count_loop = " %count_loop%
move test(%count_loop%) proto\9\
set /a "count_loop = count_loop + 1"
if %count_loop% leq %count1% (
    echo test(%count_loop%) moved
     goto while_loop1)

我可以在这里提出一些建议。

干杯,失落的Thomo

0 个答案:

没有答案