首页 > 解决方案 > 要求用户在 cmd 中输入值而不是从不同的文件中获取

问题描述

我有batch接受参数的文件,到目前为止,我正在从另一个文本文件中获取参数ClientName.txt

现在我需要从 cmd 本身获取参数,例如Enter client name:。查看我的文件

@echo off
setlocal enabledelayedexpansion
FOR /F "tokens=*" %%A in (1.ClientName.txt) DO ( 
XCOPY "..\AppIcons\%%A\drawable\*" "..\Global\Resources\" /E /F /R /Y /H   >> "..\AppIcons\%%A\copy.log"
XCOPY "..\AppIcons\%%A\SplashSc\*" "..\Global\Resources\" /E /F /R /Y /H   >> "..\AppIcons\%%A\copy.log"
)

我怎样才能做到这一点?谢谢你。

标签: windowsbatch-filecmdcommand-prompt

解决方案


在上述评论的帮助下,我得到了答案

@echo off
    set /p $client=Enter project name:

        XCOPY "..\AppIcons\%$client%\drawable-hdpi\*" "..\RisingSun\Resources\drawable-hdpi\" /E /F /R /Y /H            >> "..\AppIcons\%$client%\copy.log"
        XCOPY "..\AppIcons\%$client%\drawable-mdpi\*" "..\RisingSun\Resources\drawable-mdpi\" /E /F /R /Y /H            >> "..\AppIcons\%$client%\copy.log"
        XCOPY "..\AppIcons\%$client%\drawable-xhdpi\*" "..\RisingSun\Resources\drawable-xhdpi\" /E /F /R /Y /H          >> "..\AppIcons\%$client%\copy.log"
        XCOPY "..\AppIcons\%$client%\GoogleJsonFile\*" "..\RisingSun\" /E /F /R /Y /H       >> "..\AppIcons\%$client%\copy.log"
        XCOPY "..\AppIcons\%$client%\LoginPageImage\*" "..\RisingSun\Resources\drawable\" /E /F /R /Y /H        >> "..\AppIcons\%$client%\copy.log"
        XCOPY "..\AppIcons\%$client%\MenifestFile\*" "..\RisingSun\Properties\" /E /F /R /Y /H          >> "..\AppIcons\%$client%\copy.log"
        XCOPY "..\AppIcons\%$client%\SplashScreenImage\*" "..\RisingSun\Resources\drawable\" /E /F /R /Y /H      >> "..\AppIcons\%$client%\copy.log"

推荐阅读