diff --git a/CopyToTzj-qh.bat b/CopyToTzj-qh.bat new file mode 100644 index 0000000..0beafdf --- /dev/null +++ b/CopyToTzj-qh.bat @@ -0,0 +1,24 @@ +@echo off +cd /d %~dp0 + +chcp 65001 > nul + +set "source_folder=book" +set "destination_folder=\\192.168.0.111\home\www" + +:: 确保目标文件夹存在,如果不存在则创建它 +if not exist "%destination_folder%" ( + mkdir "%destination_folder%" +) else ( + ::del "%destination_folder%" + del /Q /S "%destination_folder%" > NUL 2>&1 + ::del 移除空的文件夹 + rd /S /Q "%destination_folder%" > NUL 2>&1 + echo "清空文件夹: %destination_folder%" +) + +:: 复制文件夹 +xcopy /E /I /Y /Q "%source_folder%" "%destination_folder%" > NUL 2>&1 + + +echo "复制完成!" \ No newline at end of file diff --git a/CopyToTzj-qh.sh b/CopyToTzj-qh.sh new file mode 100644 index 0000000..c676d7a --- /dev/null +++ b/CopyToTzj-qh.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# 定义目录路径 +SOUR_DIR="/book" +DEST_DIR="\\192.168.0.111\home\www" + +# 删除旧目录 +if [ -d "$DEST_DIR" ]; then + echo "Deleting $DEST_DIR" + rm -rf "$DEST_DIR" +else + echo "$DEST_DIR does not exist." +fi + +# 复制新目录到目标目录 +if [ -d "$SOUR_DIR" ]; then + echo "Copying $SOUR_DIR to $DEST_DIR" + cp -r "$SOUR_DIR" "$DEST_DIR" +else + echo "$SOUR_DIR does not exist." +fi + +echo "Script completed."