123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- @echo off
- chcp 65001 >nul
- echo ========================================
- echo ThCardReader x86 Release Package Script
- echo ========================================
- echo.
- :: 设置变量
- set SOURCE_DIR=E:\huaihaiProject\readCard\ThCardReader\ThCardReader\bin\x86\Release
- :: 获取英文格式的日期时间
- for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
- set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
- set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
- set "TIMESTAMP=%YYYY%%MM%%DD%_%HH%%Min%%Sec%"
- set PACKAGE_NAME=ThCardReader_x86_Release_%TIMESTAMP%
- set TEMP_DIR=%cd%\temp_%PACKAGE_NAME%
- echo Source Directory: %SOURCE_DIR%
- echo Package Name: %PACKAGE_NAME%
- echo Temp Directory: %TEMP_DIR%
- echo.
- :: 检查源目录是否存在
- if not exist "%SOURCE_DIR%" (
- echo [ERROR] Source directory does not exist: %SOURCE_DIR%
- echo Please make sure the path is correct and the project has been built.
- pause
- exit /b 1
- )
- :: 检查源目录是否有文件
- dir "%SOURCE_DIR%" >nul 2>&1
- if errorlevel 1 (
- echo [ERROR] Cannot access source directory or directory is empty.
- pause
- exit /b 1
- )
- echo [INFO] Checking source directory contents...
- dir "%SOURCE_DIR%" /b | find /c /v "" > temp_count.txt
- set /p FILE_COUNT=<temp_count.txt
- del temp_count.txt
- echo [INFO] Found %FILE_COUNT% items in source directory.
- echo.
- :: 创建临时目录
- if exist "%TEMP_DIR%" (
- echo [INFO] Removing existing temp directory...
- rmdir /s /q "%TEMP_DIR%"
- )
- echo [INFO] Creating temp directory...
- mkdir "%TEMP_DIR%"
- if errorlevel 1 (
- echo [ERROR] Failed to create temp directory.
- pause
- exit /b 1
- )
- :: 复制所有文件(不修改任何内容)
- echo [INFO] Copying all files from x86\Release directory...
- echo Source: %SOURCE_DIR%
- echo Target: %TEMP_DIR%
- echo.
- xcopy "%SOURCE_DIR%\*" "%TEMP_DIR%\" /E /I /H /Y /Q
- if errorlevel 1 (
- echo [ERROR] Failed to copy files from source directory.
- pause
- exit /b 1
- )
- :: 验证复制结果
- echo [INFO] Verifying copied files...
- dir "%TEMP_DIR%" /b | find /c /v "" > temp_count2.txt
- set /p COPIED_COUNT=<temp_count2.txt
- del temp_count2.txt
- echo [INFO] Copied %COPIED_COUNT% items successfully.
- echo.
- :: 显示复制的主要文件
- echo [INFO] Main files in package:
- if exist "%TEMP_DIR%\ThCardReader.exe" (
- echo ✓ ThCardReader.exe
- for %%f in ("%TEMP_DIR%\ThCardReader.exe") do echo Size: %%~zf bytes, Modified: %%~tf
- ) else (
- echo ✗ ThCardReader.exe [MISSING]
- )
- if exist "%TEMP_DIR%\ThCardReader.exe.config" (
- echo ✓ ThCardReader.exe.config
- ) else (
- echo ✗ ThCardReader.exe.config [MISSING]
- )
- echo.
- echo [INFO] All DLL files:
- dir "%TEMP_DIR%\*.dll" /b 2>nul
- echo.
- :: 创建ZIP包
- echo [INFO] Creating ZIP package...
- set ZIP_FILE=%PACKAGE_NAME%.zip
- :: 使用PowerShell创建ZIP(Windows 10+自带)
- powershell -Command "Compress-Archive -Path '%TEMP_DIR%\*' -DestinationPath '%ZIP_FILE%' -Force"
- if errorlevel 1 (
- echo [ERROR] Failed to create ZIP package.
- echo Please make sure PowerShell is available and try again.
- pause
- goto cleanup
- )
- :: 验证ZIP文件
- if exist "%ZIP_FILE%" (
- for %%f in ("%ZIP_FILE%") do (
- echo [SUCCESS] Package created successfully!
- echo File: %ZIP_FILE%
- echo Size: %%~zf bytes
- echo Created: %%~tf
- )
- echo.
-
- :: 显示ZIP内容统计(简化版本,兼容所有系统)
- echo [INFO] Package contents summary:
- echo Files: %COPIED_COUNT%
- for %%f in ("%ZIP_FILE%") do echo ZIP Size: %%~zf bytes
- ) else (
- echo [ERROR] ZIP package was not created.
- )
- :cleanup
- :: 清理临时目录
- echo [INFO] Cleaning up temporary files...
- if exist "%TEMP_DIR%" (
- rmdir /s /q "%TEMP_DIR%"
- echo [INFO] Temporary directory removed.
- )
- echo.
- echo ========================================
- echo Package operation completed!
- echo ========================================
- echo.
- echo IMPORTANT NOTES:
- echo - Source files were NOT modified in any way
- echo - Package contains EXACT copy of x86\Release
- echo - Package name: %PACKAGE_NAME%.zip
- echo - All files preserved as-is with original timestamps
- echo - No Chinese characters in package name
- echo.
- pause
|