首页->【软件工具包使用(SW/Software Tools Usage)】

6 1

其中FileList.txt为文件名,address.txt为保存内容为相对路径两个文件内容,如图所示

图片.png

:: ===============================
:: OpenRight
::  FUNCTION: rename the file by its name and folder name   
:: BATNAME : reneme the files
:: RELEASE Date : 07/31/18
:: Create              :Winyoo_Shiy
::Add_function  : to decrease the time, copy the files by abstract path
:: ================================
@echo off
::set the color
color 2
:: pls fill the SRC_PATH with the pattern abstract  path
set CPY_ENV_PATH=%C:\Windows\System32%
set  SRC_PATH=C:\Users\Winyoo_shiy\Desktop\tst_addr_merge\tst_addr_merge
:: pls fill the DIR_PATH with cpy target path
set  DIR_PATH=C:\Users\Winyoo_shiy\Desktop\tst_addr_merge\tst_addr_merge\pg3
:: set  the file list
set  list=C:\Users\Winyoo_shiy\Desktop\tst_addr_merge\tst_addr_merge
:: cd  %SRC_PATH%
:: echo hello_debug
:: pause
setlocal enabledelayedexpansion
::for /f  "delims=" %%a in (' dir /a-d/s/b  %SRC_PATH%\*.binl ') do (
set fdstrf=bin
set fdstra=.
set addrCnt=0
set fileListCnt=0
::get the row of file,default:the same as Filelist.txt and address.txt
set rowNo=0
for /f "tokens=* delims=" %%b in ('findstr /i /c:%fdstrf% %list%\Filelist.txt') do (
        set /a rowNo=rowNo+1
        )
::merge the file by column according to the same rowno        
for /f "tokens=* delims=" %%i in ('findstr /i /c:%fdstrf% %list%\Filelist.txt') do (
       set /a fileListCnt=fileListCnt+1
       for /f "tokens=* delims=." %%b in ('findstr /i /c:%fdstra% %list%\address.txt') do (
       set /a addrCnt=addrCnt+1
       if !fileListCnt!==!addrCnt! echo.%SRC_PATH%%%b\%%i >> %list%\binlList.tmp
       if !addrCnt!==%rowNo% ( set addrCnt=0 )
       )
  )
::copy the files by the context of binlList files
set cnt=0
for /f "tokens=* delims=" %%b in ('findstr /i /c:%fdstrf% %list%\binlList.tmp') do (
        xcopy  %%b  %DIR_PATH%  /y
        set /a cnt=cnt+1        
        )
del /f binlList.tmp
:: end of batfile

作者于2018-08-28 20:58:21修改!
楼主可见

  1. shwnyoo 1#

    对前期的批量复制的bat进行了优化,节约了运行时间