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

11 2

前一篇将FileList 和address分开存储,本例子将这两个信息合在一起,其格式如图所示:


图片.png

:: ===============================
:: OpenRight@Otham.Shi,ShangHai,China
::  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
::                            to decrease the operation  of del txt file , use the binlList.tmp
::                            to decrease the number of input files, cpy 2 column from excel.
:: ================================

@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\shiotha\Desktop\Kepler_93k_testprogram\V93K
:: pls fill the DIR_PATH with cpy target path
set  DST_PATH=C:\Users\shiotha\Desktop\convert_completed\wavetable208\210\pASYNC1_pSCAN1_pPARA7_WFT9X4_MPT_x16_600_pg3
:: set  the file list
set  list=C:\Users\shiotha\Desktop\tst_addr_merge
:: cd  %SRC_PATH%
:: echo hello_debug
setlocal enabledelayedexpansion
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=1 delims=    " %%i in ('findstr /i /c:%fdstrf% %list%\Filelist.txt') do (
       set /a fileListCnt=fileListCnt+1
       set filename=%%i
       for /f "tokens=3 delims=." %%b in ('findstr /i /c:%fdstra% %list%\Filelist.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  %DST_PATH%  /y
        set /a cnt=cnt+1        
        )
del  /a /f /q %list%\binlList.tmp
:: end of batfile


楼主可见

  1. shwnyoo 2#

    ***此内容已隐藏,只有楼主可见***

  2. shwnyoo 1#

    bat批量复制之升级版2  对findstr的高级应用