user2840236
user2840236

Reputation: 21

How to use variable in xcopy since source file name is dynamic?

For example I have

xcopy "C:\windows\match\goal.cfg" "c:\Program Files\Gate\" /e /i /h /r /k /y

where the name of the folder match is dynamic and always changes. How can I variablize the path directly to point a file in match folder to copy to gate folder in program files?

Upvotes: 2

Views: 7840

Answers (1)

Ben Smith
Ben Smith

Reputation: 20230

If you want to pass a folder name variable into the batch file you could use:

@echo off
set /p "folder=Enter folder name: "

xcopy "C:\windows\%folder%\goal.cfg" "c:\Program Files\Gate\" /e /i /h /r /k /y

Upvotes: 3

Related Questions