4

I want to create a variable in a batch file and I want to assign a path of a text file to to this variable. After that, I want to use this variable to copy that file. How can I do this?

Thank you,

1 Answer 1

8

The general idea is this:

SET filename=c:\path\to\file.txt
COPY "%filename%" c:\destination

Note the quotes around %filename%: they are necessary to make the command work if the path or file name contains spaces.

Sign up to request clarification or add additional context in comments.

2 Comments

I want to ask a question too, I have two variables: SET source=C:\Temp*.* and SET targetMove=d:\moveTemp\ I want to move source directory to target directory by using this line: move /-y "%source%" "%targetMove%" but it does not work. How can I do this process? Thank you,
@aprogrammer: If it does not work then you are passing the wrong parameters to move.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.