1

Basically I want to use 2020 minus a variable to make another variable.

This is the code I have at the moment.

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

can anybody run make any suggestions as how to help.

Thanks

Sam Inc.

Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • 1
    possible duplicate of [Calculating the sum of two variables in a batch script](http://stackoverflow.com/questions/10674974/calculating-the-sum-of-two-variables-in-a-batch-script) – Alex K. Jan 30 '14 at 14:02

2 Answers2

3

A quick search yielded the following relevant answer. Use "set /a".

Calculating the sum of two variables in a batch script

Community
  • 1
  • 1
furrymitn
  • 51
  • 2
1

It would be easier to identify your question if your provided code example was legible.

You can make it legible by highlighting it and clicking on the brackets.

I'm sure I'll be able to provide what you need if I could see what you're working with.

Thanks for taking the time to make your example more legible.

I believe your confusion is located where I have placed a "rem". That may be where you want to perform your calculation (or some other variation similar).

I placed an example for performing the calculation, then placed a goto statement so that you can look at the results.

This might help you to get a grip of resolving your issue:

@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

By the way, I placed an "@echo off" at the top to make it easier to read the flow when executing the script.

Also, you might consider removing the "cls" that you have until you have it debugged. While debugging you need to be able to view the history of what has happened.

L. D. James
  • 1,679
  • 1
  • 22
  • 35