Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables 如何从一个数字中减去一个变量。批处理文件_Variables_Batch File_Sum - Fatal编程技术网

Variables 如何从一个数字中减去一个变量。批处理文件

Variables 如何从一个数字中减去一个变量。批处理文件,variables,batch-file,sum,Variables,Batch File,Sum,基本上我想用2020减去一个变量来做另一个变量 这是我目前掌握的密码 echo Type Your Year, then press enter. set/p "myear=>" echo Type the year of the person's stuff you want to copy, then press enter. set/p "yearofv=>" cls set/p "myyear="2020-%myear%" set/p year="2020-%yearofv%

基本上我想用2020减去一个变量来做另一个变量

这是我目前掌握的密码

echo Type Your Year, then press enter.
set/p "myear=>"
echo Type the year of the person's stuff you want to copy, then press enter.
set/p "yearofv=>"
cls
set/p "myyear="2020-%myear%"
set/p year="2020-%yearofv%"
md "c:\%myyear%\%myuser%\My Documents\File Copier\%user%'s Data\Documents"
copy "c:\%year%\%user%\My Documents" "c:\%myyear%\%myuser%\My Documents\File Copier\%user%'s Data\Document
有谁能就如何提供帮助提出建议吗

谢谢


Sam Inc.

快速搜索得到以下相关答案。使用“set/a”


快速搜索得到以下相关答案。使用“set/a”


如果您提供的代码示例清晰易读,则更容易识别您的问题

您可以通过突出显示并单击括号使其易读

如果我能了解你的工作情况,我肯定能提供你所需要的

感谢您抽出时间让您的示例更清晰易读

我相信你的困惑就在我放置“rem”的地方。这可能是您要执行计算的地方(或其他类似的变体)

我放置了一个执行计算的示例,然后放置了一个goto语句,以便您可以查看结果

这可能有助于您掌握解决问题的方法:

@echo off

echo Type Your Year, then press enter.
rem set/p "myear=>"
set /p myyear="Enter myyear: " %=%
echo Type the year of the person's stuff you want to copy, then press enter.
rem set/p "yearofv=>"
set /p yearofv="Year of v: " %=%

cls
echo This is the difference between 2020 and "myyear..."
set/a difference=2020-%myyear%
echo %difference%

goto skip

set/p year="2020-%yearofv%"
md "c:\%myyear%\%myuser%\My Documents\File Copier\%user%'s Data\Documents"
copy "c:\%year%\%user%\My Documents" "c:\%myyear%\%myuser%\My Documents\File Copier\%user%'s Data\Document

:skip
顺便说一下,我在顶部放置了一个“@echo off”,以便在执行脚本时更容易读取流


也可以考虑删除已经调试过的“CLS”。调试时,您需要能够查看所发生事件的历史记录。

如果您提供的代码示例清晰易读,则更容易识别您的问题

您可以通过突出显示并单击括号使其易读

如果我能了解你的工作情况,我肯定能提供你所需要的

感谢您抽出时间让您的示例更清晰易读

我相信你的困惑就在我放置“rem”的地方。这可能是您要执行计算的地方(或其他类似的变体)

我放置了一个执行计算的示例,然后放置了一个goto语句,以便您可以查看结果

这可能有助于您掌握解决问题的方法:

@echo off

echo Type Your Year, then press enter.
rem set/p "myear=>"
set /p myyear="Enter myyear: " %=%
echo Type the year of the person's stuff you want to copy, then press enter.
rem set/p "yearofv=>"
set /p yearofv="Year of v: " %=%

cls
echo This is the difference between 2020 and "myyear..."
set/a difference=2020-%myyear%
echo %difference%

goto skip

set/p year="2020-%yearofv%"
md "c:\%myyear%\%myuser%\My Documents\File Copier\%user%'s Data\Documents"
copy "c:\%year%\%user%\My Documents" "c:\%myyear%\%myuser%\My Documents\File Copier\%user%'s Data\Document

:skip
顺便说一下,我在顶部放置了一个“@echo off”,以便在执行脚本时更容易读取流

也可以考虑删除已经调试过的“CLS”。调试时,您需要能够查看所发生事件的历史记录。

可能重复的可能重复的