Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a String variable and use batch

Tags:

batch-file

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,

like image 786
eponymous Avatar asked Feb 21 '23 04:02

eponymous


1 Answers

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.

like image 158
Jon Avatar answered Mar 20 '23 03:03

Jon