如何在使用 xcopy 时添加一个或多个扩展

如何在使用 xcopy 时添加一个或多个扩展
@echo off
setlocal enabledelayedexpansion
for %%A in (*.bat) do (
   
   for /f "delims=" %%B in ("%%A") do set fname=%%~nB
   for /f "delims=" %%C in ("%%A") do set fextn=%%~xC
   for /f "tokens=1* delims=_" %%D in ("!fname!") do set folname=%%D
   echo folder name !folname!

echo
xcopy /Y "E:\folder1\folder2\!folname!\folder3\" "G:\folder1\folder2\spi-!folname!\folder3" 
rem (e.g., *.jpg; *.tiff; *.eps)
xcopy /E /Y "E:\folder1\folder2\!folname![/b]\folder3\" "G:\folder1\folder2\spi-!folname!\folder3" 
rem (e.g., subfolder)
)
echo Finished
pause

答案1

@echo off
setlocal enabledelayedexpansion
for %%A in (*.bat) do (
   
   for /f "delims=" %%B in ("%%A") do set fname=%%~nB
   for /f "delims=" %%C in ("%%A") do set fextn=%%~xC
   for /f "tokens=1* delims=_" %%D in ("!fname!") do set folname=%%D
   echo folder name !folname!

echo.

xcopy /Y "E:\folder1\folder2\!folname!\folder3\*.jpg" "G:\folder1\folder2\spi-!folname!\folder3" 
xcopy /Y "E:\folder1\folder2\!folname!\folder3\*.tiff" "G:\folder1\folder2\spi-!folname!\folder3"
xcopy /Y "E:\folder1\folder2\!folname!\folder3\*.eps" "G:\folder1\folder2\spi-!folname!\folder3"
xcopy /E /Y "E:\folder1\folder2\!folname!\folder3\*" "G:\folder1\folder2\spi-!folname!\folder3" 
)
echo Finished
pause

相关内容