1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| @echo off set source_folder=%OneDrive%\文档\Obsidian\1-blog set destination_folder=%OneDrive%\文档\blog\source\_posts
echo Source folder: "%source_folder%" echo Destination folder: "%destination_folder%"
echo Creating a ZIP archive of the source folder... for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I set datetime=%datetime:~0,8%-%datetime:~8,6% set archive_name=%source_folder%_%datetime%.zip
powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; $src_folder = [System.IO.Path]::GetFullPath('%source_folder%'); $dst_zip = [System.IO.Path]::GetFullPath('%archive_name%'); [IO.Compression.ZipFile]::CreateFromDirectory($src_folder, $dst_zip); }" echo ZIP archive created: %archive_name%
echo Deleting files in destination folder...
for /r "%destination_folder%" %%f in (*.*) do ( del "%%f" )
echo Copying files...
for /r "%source_folder%" %%f in (*.*) do ( echo F | xcopy /d /y "%%f" "%destination_folder%" )
echo Copying completed. pause
echo Running Hexo commands... cd %OneDrive%\文档\blog\
call hexo clean call hexo generate call hexo deploy
echo Hexo commands completed. pause
|