批处理文件逐步使用不同的 cmd

批处理文件逐步使用不同的 cmd

我正在创建一个批处理文件来连续执行一些进程。

  1. 首先我必须根据输入文件夹/子文件夹创建 3 个单独的文件夹
  2. 然后使用 copy cmd 从文件夹 1 到文件夹 2
  3. 然后同时将 cmd 从文件夹 1 复制到文件夹 3
rem Define input and output base folders

set BaseInputDir=F:\Input\
set BaseOutputDir=F:\Output1\
    
rem Look for all TIF files under inoput folder (and subfolders)
for /F "tokens=*" %%F in ('dir /a /s /b /a-d "%BaseInputDir%\*.tif"') do (

您能建议我如何在一个批处理文件中创建 3 次文件夹(包含所有子文件夹)吗?

  1. 输出文件夹命名为输出 1
  2. 另一个输出文件夹 - 作为输出 2
  3. 另一个输出文件夹 - 作为输出 3

rem Log that we are copying this file

ECHO Copying files "%%~F" to "!OutPutDir!%%~nF.tif"

rem Do the copy

copy "%%~F"  "!OutPutDir!%%~nF.tif"
)

我怎样才能实现复制cmd或任何其他cmd

  • 输入文件夹至输出 1
  • 输出 1 至输出 2
  • 输出 1 至输出 3

答案1

答案已更新!!

请看一下,这是否符合预期: CopyTo3Foders.gif

@echo off
rem Define input and output base folders

set BaseInputDir=F:\Input
set BaseOutputDir=F:\Output
set Files=*.tif

IF not exist "%BaseOutputDir%" md "%BaseOutputDir%"                                        
xcopy /i /e /f /h /y "%BaseInputDir%\%Files%" "%BaseOutputDir%"1>"%Date:/=-%.log"

IF not exist "%BaseOutputDir%1" md "%BaseOutputDir%1"
xcopy /i /e /f /h /y "%BaseOutputDir%\%Files%" "%BaseOutputDir%1"1>>"%Date:/=-%.log"

IF not exist "%BaseOutputDir%2" md "%BaseOutputDir%2"
xcopy /i /f /e /h /y "%BaseOutputDir%1\%Files%" "%BaseOutputDir%2"1>>"%Date:/=-%.log"

相关内容