Search code examples
variablesbatch-filefilenames

Write Batch variables to the filename


i have a problem with batch and i can´t find the answer. I want to write a variable into the name of a file, that will be created. :) I want to make a Joomla Helper Batch. It should generate a grid for Modules. It is only for my purposes. This is my example code.

@echo off set /pmodulename = Please insert the name of the Module: echo ^<?xml version^=^'1.0^' encoding^=^'utf-8^' ?^> ^<extension type^=^'module^' version^=^'3.0^' client^=^'site^' method^=^'upgrade^'^> > "%modulename%".xml

After executing the batch file, there is a xml file, but it has no name. So how can i append the variable name to the file?

Greetings Kevin Grahn


Solution

  • Looking at that you have a space before the = remove that and it should be fine

    Before:

    set /pmodulename = Please insert the name of the Module:
    

    After:

    set /pmodulename= Please insert the name of the Module:
    

    Just run your line in a cmd window then run set to see the list you will see the variable has the space.