当前位置:   article > 正文

使用批处理批量复制文件并重命名_1个文件复制100分并命名

1个文件复制100分并命名

    在工作中,有时候,需要把一个文件复制为多份,并且重新命名。比如,把20170603094607000.mp3复制100份,文件依次命名为20170603094607001.mp3 ~ 20170603094607100.mp3。
  1、首先,生成文件列表,每一行记录一个文件名,这些文件名都保存在FileList.txt中。
  
//CreateFileList.bat

REM @echo off
@echo off

set name=FileList.txt
set time=2017060309460
set exc=.mp3
for /l %%i in (7001,1,7100) do (
echo %time%%%i%exc% >>%name%
)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

//FileList.txt

20170603094607001.mp3 
20170603094607002.mp3 
20170603094607003.mp3 
20170603094607004.mp3 
20170603094607005.mp3 
20170603094607006.mp3 
20170603094607007.mp3 
20170603094607008.mp3 
20170603094607009.mp3 
20170603094607010.mp3 
20170603094607011.mp3 
20170603094607012.mp3 
20170603094607013.mp3 
20170603094607014.mp3 
20170603094607015.mp3 
20170603094607016.mp3 
20170603094607017.mp3 
20170603094607018.mp3 
20170603094607019.mp3 
20170603094607020.mp3 
20170603094607021.mp3 
20170603094607022.mp3 
20170603094607023.mp3 
20170603094607024.mp3 
20170603094607025.mp3 
20170603094607026.mp3 
20170603094607027.mp3 
20170603094607028.mp3 
20170603094607029.mp3 
20170603094607030.mp3 
20170603094607031.mp3 
20170603094607032.mp3 
20170603094607033.mp3 
20170603094607034.mp3 
20170603094607035.mp3 
20170603094607036.mp3 
20170603094607037.mp3 
20170603094607038.mp3 
20170603094607039.mp3 
20170603094607040.mp3 
20170603094607041.mp3 
20170603094607042.mp3 
20170603094607043.mp3 
20170603094607044.mp3 
20170603094607045.mp3 
20170603094607046.mp3 
20170603094607047.mp3 
20170603094607048.mp3 
20170603094607049.mp3 
20170603094607050.mp3 
20170603094607051.mp3 
20170603094607052.mp3 
20170603094607053.mp3 
20170603094607054.mp3 
20170603094607055.mp3 
20170603094607056.mp3 
20170603094607057.mp3 
20170603094607058.mp3 
20170603094607059.mp3 
20170603094607060.mp3 
20170603094607061.mp3 
20170603094607062.mp3 
20170603094607063.mp3 
20170603094607064.mp3 
20170603094607065.mp3 
20170603094607066.mp3 
20170603094607067.mp3 
20170603094607068.mp3 
20170603094607069.mp3 
20170603094607070.mp3 
20170603094607071.mp3 
20170603094607072.mp3 
20170603094607073.mp3 
20170603094607074.mp3 
20170603094607075.mp3 
20170603094607076.mp3 
20170603094607077.mp3 
20170603094607078.mp3 
20170603094607079.mp3 
20170603094607080.mp3 
20170603094607081.mp3 
20170603094607082.mp3 
20170603094607083.mp3 
20170603094607084.mp3 
20170603094607085.mp3 
20170603094607086.mp3 
20170603094607087.mp3 
20170603094607088.mp3 
20170603094607089.mp3 
20170603094607090.mp3 
20170603094607091.mp3 
20170603094607092.mp3 
20170603094607093.mp3 
20170603094607094.mp3 
20170603094607095.mp3 
20170603094607096.mp3 
20170603094607097.mp3 
20170603094607098.mp3 
20170603094607099.mp3 
20170603094607100.mp3 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100

    2、使用批处理,根据FileList.txt里的内容,将20170603094607000.mp3复制100次,以生成100个不同名称的文件。
  //CopyA4.bat

REM @echo off
@echo off
set str=20170603094607000.mp3
for /f %%i in (FileList.txt) do (echo F|(xcopy %str% %%i))
  • 1
  • 2
  • 3
  • 4

    3、将FileList.txt、CopyA4.bat、20170603094607000.mp3放在同一个目录下,双击CopyA4.bat就可以生成100多个名称不同但内容相同的.mp3文件 了。效果如下:

图(1) 将.bat、.txt放在同一个目录,然后双击CopyA4.bat即可生成100多个文件

注意:
  .bat中支持的Int整型范围为:-2147483648~+2147483647
  所以,对于范围超过了Int的数字,需要分成几块进行处理。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/73372
推荐阅读
相关标签
  

闽ICP备14008679号