rem template file path set UPLOAD_PATH=d:/data/zcoais/data/upload
时间: 2023-09-21 21:06:38 浏览: 171
你的第一个问题是:rem template file path set UPLOAD_PATH=d:/data/zcoais/data/upload,这是一个设置模板文件路径的命令行语句。它将 UPLOAD_PATH 变量设置为 d:/data/zcoais/data/upload,这意味着在执行相关程序时,程序将在该路径下寻找模板文件。
相关问题
#!/bin/bash # Assets TEST_IMG=demo.png SDK_ROOT=$PWD TEST_ROOT=$PWD BIN_NAME=test_demo DEVICE_TEST_PATH=/data/local/tmp/ts_ai_sdk_test MODEL_PATH=/sdcard/models RUSULT=/data/local/tmp/ts_ai_sdk_test/results/ RUNTIME=DSP adb root # Push test assets adb shell rm -rf $DEVICE_TEST_PATH # adb shell rm -rf $MODEL_PATH adb shell mkdir -p $DEVICE_TEST_PATH/jpgs adb shell mkdir -p $DEVICE_TEST_PATH/results/post_result adb shell mkdir -p $DEVICE_TEST_PATH/results/img_result #adb shell mkdir -p $MODEL_PATH adb push images/* $DEVICE_TEST_PATH/jpgs # Push SNPE libraries adb push ${SDK_ROOT}/libs/ $DEVICE_TEST_PATH adb push ${SDK_ROOT}/models/model.exf $DEVICE_TEST_PATH/ # Push executable adb push build/$BIN_NAME $DEVICE_TEST_PATH # Test adb shell "chmod +x $DEVICE_TEST_PATH/$BIN_NAME" echo "Running on Android device ..." echo "LD_LIBRARY_PATH='$DEVICE_TEST_PATH/libs' $DEVICE_TEST_PATH/$BIN_NAME $DEVICE_TEST_PATH/jpgs $RUSULT $DEVICE_TEST_PATH/model.exf" echo "Done." adb shell "LD_LIBRARY_PATH='$DEVICE_TEST_PATH/libs' $DEVICE_TEST_PATH/$BIN_NAME $DEVICE_TEST_PATH/jpgs $RUSULT $DEVICE_TEST_PATH/model.exf" # Pull result adb pull $DEVICE_TEST_PATH/results/ . sleep 1改为bat脚本
将该脚本转换为 Windows 的 batch 脚本,需要进行以下修改:
1. 更改第一行为 `@echo off`,表示关闭命令回显。
2. 将变量的赋值方式从 `$变量名=值` 改为 `set 变量名=值`。
3. 将 `adb` 命令行中的路径分隔符 `/` 改为 Windows 下的路径分隔符 `\`。
4. 在执行命令行时需要使用 `call` 命令。
修改后的 batch 脚本如下:
```
@echo off
REM Assets
set TEST_IMG=demo.png
set SDK_ROOT=%cd%
set TEST_ROOT=%cd%
set BIN_NAME=test_demo
set DEVICE_TEST_PATH=/data/local/tmp/ts_ai_sdk_test
set MODEL_PATH=/sdcard/models
set RESULT=/data/local/tmp/ts_ai_sdk_test/results/
set RUNTIME=DSP
REM Push test assets
adb root
adb shell rm -rf %DEVICE_TEST_PATH%
adb shell mkdir -p %DEVICE_TEST_PATH%/jpgs
adb shell mkdir -p %DEVICE_TEST_PATH%/results/post_result
adb shell mkdir -p %DEVICE_TEST_PATH%/results/img_result
adb push images\* %DEVICE_TEST_PATH%/jpgs
REM Push SNPE libraries
adb push %SDK_ROOT%\libs\ %DEVICE_TEST_PATH%
adb push %SDK_ROOT%\models\model.exf %DEVICE_TEST_PATH%\
REM Push executable
adb push build\%BIN_NAME% %DEVICE_TEST_PATH%\
REM Test
adb shell "chmod +x %DEVICE_TEST_PATH%\%BIN_NAME%"
echo Running on Android device ...
echo "LD_LIBRARY_PATH='%DEVICE_TEST_PATH%\libs' %DEVICE_TEST_PATH%\%BIN_NAME% %DEVICE_TEST_PATH%/jpgs %RESULT% %DEVICE_TEST_PATH%/model.exf"
echo Done.
call adb shell "LD_LIBRARY_PATH='%DEVICE_TEST_PATH%\libs' %DEVICE_TEST_PATH%\%BIN_NAME% %DEVICE_TEST_PATH%/jpgs %RESULT% %DEVICE_TEST_PATH%\model.exf"
REM Pull result
adb pull %DEVICE_TEST_PATH%/results/ .
timeout /t 1
```
@echo off setlocal EnableDelayedExpansion set "texturepacker=E:\TexturePacker\bin\TexturePacker.exe" set "outputDir=G:\tp" for /r %%i in (.png) do ( set "path=%%~dpi" set "a=false" for /f %%j in ('dir /b /a-d "!path!".png') do ( set "a=true" ) if !a! == true ( echo !path! REM echo %%i REM echo %%~nxi REM echo %%~pi set "a=%%~pi" REM echo !a! set "a=!a:\act=!" set "b=!a:=!" REM echo !b! set "c=!outputDir!;!b!" set "outpath=!c:;=!" echo !outpath! "%texturepacker%" --sheet "!outpath!.png" --data "!outpath!.plist" --trim --allow-free-size --enable-rotation --max-size 1024 !path! ) else ( echo false ) ) echo Done. pause 优化这段代码我想在png资源时对该文件夹进行操作不用对这个文件夹中的每个png资源进行遍历
以下是我优化后的代码,它将只对包含PNG资源的文件夹进行操作,而不需要遍历每个PNG资源:
```
@echo off
setlocal EnableDelayedExpansion
set "texturepacker=E:\TexturePacker\bin\TexturePacker.exe"
set "outputDir=G:\tp"
for /d /r %%i in (*) do (
set "a=false"
for /f %%j in ('dir /b /a-d "%%i\*.png"') do (
set "a=true"
)
if !a! == true (
set "path=%%i"
set "a=!path:\act=!"
set "b=!a:=!"
set "c=!outputDir!;!b!"
set "outpath=!c:;=!"
echo !outpath!
"%texturepacker%" --sheet "!outpath!.png" --data "!outpath!.plist" --trim --allow-free-size --enable-rotation --max-size 1024 !path!\*.png
)
)
echo Done.
pause
```
此代码使用 `for /d /r` 循环来遍历包含PNG资源的文件夹。然后,对于每个包含PNG资源的文件夹,它会使用 `dir` 命令检查是否存在PNG文件,并使用 `set` 命令设置 `a` 变量以指示是否存在PNG文件。如果存在PNG文件,则将路径转换为可用于输出的格式,并使用 `TexturePacker` 命令进行操作。
阅读全文