第1个回答 2022-05-17
@echo off & title 根据列表复制文件夹到指定位置 By 依梦琴瑶
::设置文件夹列表文件
set List=FolderList.txt
::设置主源目录
set SrcFolder=D:\源目标目录
::设置指定保存目录
set SavFolder=E:\最终保存目录
for /f "delims=" %%a in ('type "%List%"') do (
if exist "%SrcFolder%\%%~a\." (
xcopy /s /e /y "%SrcFolder%\%%~a\" "%SavFolder%\%%~a\"
) else (
echo 指定的目录 "%%~a" 不存在。
)
)
pause
脚本保存编码务必设为ANSI,以免中文字符出现乱码。
第2个回答 2022-08-31
不清楚你的实际文件/情况,仅以问题中的样例说明及猜测为据;以下代码复制粘贴到记事本,另存为***.bat,编码选ANSI@echo off&cd /d "%~dp0"
rem 根据一个txt文本文件内列出的文件名称前缀字符,从一个指定目录里查找出符合条件的子文件夹并拷贝/复制到另一个指定目录里
set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
set "oldfolder=D:\xxx\原文件夹"
set "newfolder=E:\yyy\新文件夹"
set "txtfille=***.txt"
if not exist "%oldfolder%" (echo;"%oldfolder%" 未找到&pause&exit)
if not exist "%newfolder%" md "%newfolder%"
if not exist "%txtfille%" (echo;"%txtfille%" 未找到&pause&exit)
if "%oldfolder:~-1%" equ "\" set "oldfolder=%oldfolder:~,-1%"
if "%newfolder:~-1%" equ "\" set "newfolder=%newfolder:~,-1%"
for /f "delims=" %%a in ('type "%txtfille%"') do (
for /f "delims=" %%b in ('dir /ad-h/b "%oldfolder%\%%a_*" 2^>nul') do (
echo;"%oldfolder%\%%~nxb" --^> "%newfolder%"
)
)
echo;%#% +%$%%$%/%_% %z%
pause
exit
第3个回答 2022-08-29
不清楚你的实际文件/情况,仅以问题中的样例说明及猜测为据;以下代码复制粘贴到记事本,另存为***.bat,编码选ANSI@echo off&cd /d "%~dp0"
rem 根据一个txt文本文件内列出的文件名称前缀字符,从一个指定目录里查找出符合条件的子文件夹并拷贝/复制到另一个指定目录里
set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
set "oldfolder=D:\xxx\原文件夹"
set "newfolder=E:\yyy\新文件夹"
set "txtfille=***.txt"
if not exist "%oldfolder%" (echo;"%oldfolder%" 未找到&pause&exit)
if not exist "%newfolder%" md "%newfolder%"
if not exist "%txtfille%" (echo;"%txtfille%" 未找到&pause&exit)
if "%oldfolder:~-1%" equ "\" set "oldfolder=%oldfolder:~,-1%"
if "%newfolder:~-1%" equ "\" set "newfolder=%newfolder:~,-1%"
for /f "delims=" %%a in ('type "%txtfille%"') do (
for /f "delims=" %%b in ('dir /ad-h/b "%oldfolder%\%%a_*" 2^>nul') do (
echo;"%oldfolder%\%%~nxb" --^> "%newfolder%"
)
)
echo;%#% +%$%%$%/%_% %z%
pause
exit
第4个回答 2022-08-31
不清楚你的实际文件/情况,仅以问题中的样例说明及猜测为据;以下代码复制粘贴到记事本,另存为***.bat,编码选ANSI@echo off&cd /d "%~dp0"
rem 根据一个txt文本文件内列出的文件名称前缀字符,从一个指定目录里查找出符合条件的子文件夹并拷贝/复制到另一个指定目录里
set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
set "oldfolder=D:\xxx\原文件夹"
set "newfolder=E:\yyy\新文件夹"
set "txtfille=***.txt"
if not exist "%oldfolder%" (echo;"%oldfolder%" 未找到&pause&exit)
if not exist "%newfolder%" md "%newfolder%"
if not exist "%txtfille%" (echo;"%txtfille%" 未找到&pause&exit)
if "%oldfolder:~-1%" equ "\" set "oldfolder=%oldfolder:~,-1%"
if "%newfolder:~-1%" equ "\" set "newfolder=%newfolder:~,-1%"
for /f "delims=" %%a in ('type "%txtfille%"') do (
for /f "delims=" %%b in ('dir /ad-h/b "%oldfolder%\%%a_*" 2^>nul') do (
echo;"%oldfolder%\%%~nxb" --^> "%newfolder%"
)
)
echo;%#% +%$%%$%/%_% %z%
pause
exit