• Welcome to the PopMalt Forums! Whether you're new to forums or a veteran, welcome to our humble home on the web! We're a 20-year old forum community with thousands of discussions on entertainment, lifestyle, leisure, and more.

    Our rules are simple. Be nice and don't spam. Registration is free, so what are you waiting for? Join today!.

Dynamic variables in a .bat file?

Mirage

Secret Agent
Staff member
V.I.P.
Does anyone here know how I can create a .bat file dynamically and then run it? Is this something that I would do in ASP/

Basically I am looking to run a single line of code but one part of it will need to be different each time the file is loaded.

Any ideas?
 

Mr_Snipes

Registered Member
I am not sure if you can get a .bat to be created and run on the fly.

What are you trying to do?
 

Mr_Snipes

Registered Member
Here is the code for a .bat file to create a filename using today's date

Code:
@echo off
:: set a variable for placing today's date
set getDate=none
:: get todays date and set it in the variable
for /F "tokens=2-4 delims=/ " %%a in ('date /t') do set getDate=%%a%%b%%c
:: create the new File name and place it in a variable
set newName=databasebackup%getDate%.sql
:: create the file using the variable it was placed in
type NUL>%newName%
You may need to play with it a little bit depending on what you have for a delimiter and how it echos the date
 
Last edited:
Top