如何在文本文件中使用批处理文件变量? [英] how to use batch file variable within text file?

查看:66
本文介绍了如何在文本文件中使用批处理文件变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用文本文件中批处理文件中的变量.不确定实现这一目标的最佳和最简便的方法是什么.

I need to use variable from batch file within a text file. Not sure what's the best and easiest way to achieve that.

批处理文件代码:

set back=%cd%
for /d %%i in (C:\input\*) do (
cd "%%i"
set x=%%~nxi
CALL E:\FileMoving_run.bat --context=Default --context_param prop_file_move=C:\file_move.txt
cd %back%
pause
)
cd %back%

下面指定的文本文件-C:\ file_move.txt的内容.我试图通过这里的方式肯定是行不通的.

Content of text file -C:\file_move.txt specified below. The way I am trying to pass here is definitely not working.

path=C:\Metadata_input\%x%\
elec_path=C:\OHD\%x%\

推荐答案

根据我对您问题的理解,您可以尝试:

Based upon my understanding of your question, you could try:

@For /D %%A In ("C:\input\*")Do @(
    (Echo path=C:\Metadata_input\%%~nxA\
    Echo elec_path=C:\OHD\%%~nxA\)>"C:\file_move.txt"
    Call "E:\FileMoving_run.bat" --context=Default --context_param prop_file_move="C:\file_move.txt"
)
@Del "C:\file_move.txt"

这篇关于如何在文本文件中使用批处理文件变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆