Computing.Net > Forums > Programming > Batch that creates batch files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch that creates batch files

Reply to Message Icon

Name: fuzzymango209
Date: October 18, 2008 at 09:42:38 Pacific
OS: microsoft windows xp medi
CPU/Ram: 2.01 Ghz 1.87 gb or ram
Product: Gateway 64 bit dual proce
Comment:

I am trying to make a batch file that when clicked will create a blank batch file and let you type in the name then it will automatically save it as a .bat file
I am only skilled enough to do the following whick just lets you drag a txt document onto to it then name it and it pops out as a batch file
@echo off
cls
set /p var=File name:%var%
cls

RENAME %1 "%var%.bat"

Fuzzymango209



Sponsored Link
Ads by Google

Response Number 1
Name: Judago
Date: October 18, 2008 at 15:25:54 Pacific
Reply:

The batch below should do it, it will automatically append a .bat file extension if you don't add .bat or .cmd to the end of your filename.


@ECHO OFF
:INPUT
CLS
SET /P FLNM=PLEASE INPUT A FILE NAME FOR YOUR NEW BATCH FILE. /Q EXITS.
IF NOT DEFINED FLNM GOTO INPUT
IF /I "%FLNM%"=="/Q" GOTO :EOF
IF /I NOT "%FLNM:~-4%"==".BAT" IF /I NOT "%FLNM:~-4%"==".CMD" SET FLNM=%FLNM%.BAT
IF NOT EXIST "%FLNM%" (COPY NUL "%FLNM%") ELSE ECHO "%FLNM%" ALREADY EXISTS IN THIS DIRECTORY.&&PAUSE&&GOTO INPUT
START NOTEPAD "%FLNM%"


Here's the one I personally use(except for notepad), I don't like to prompted for a file name:


@ECHO OFF
IF NOT EXIST NEW.BAT GOTO MKR
SET COUNT=2
:NWE
IF EXIST NEW%COUNT%.BAT SET /A COUNT+=1&&GOTO NWE
:MKR
ECHO @ECHO OFF>NEW%COUNT%.BAT
START NOTEPAD NEW%COUNT%.BAT

It may not be the most elegant solution but it does the job just fine....


0

Response Number 2
Name: pball
Date: October 20, 2008 at 06:37:11 Pacific
Reply:

I got tired of renaming or saving txt files at batch scripts so i whipped this up.

@echo off
echo Enter name of batch file
set /p name=
echo Enter location to save file
set /p location=
echo @echo off > %location%\%name%.bat

This will ask for the name then a location. So typing in Hey for the name and h:\ for location will create H:\Hey.bat


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


VBScript to connect to SQ... Renaming alot of files



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch that creates batch files

Batch file to create directories www.computing.net/answers/programming/batch-file-to-create-directories/9581.html

Batch File to Create a Shortcut www.computing.net/answers/programming/batch-file-to-create-a-shortcut/13374.html

Creating a kill batch file. www.computing.net/answers/programming/creating-a-kill-batch-file/7918.html