Saturday, June 4, 2011

File Maker v0.1

This is a really silly project.
This batch file created a file of the name and extension in the location you enter in it.
You can do that without it and much faster, but I mad it so I had to share it with you.
It uses many commands that you might find useful in other batch files, if you are new to batch files.

Here is the code

@echo off
title File Maker v0.1
color 0a

:back
cls
echo.
echo  Enter file location
set/p "loc="
echo.
echo  Enter filename with extension
set/p "file="
cls
echo.
echo  File location
echo  %loc%
echo.
echo  File name
echo  %file%

:top
echo.
echo Create File
echo Y for Yes
echo N for No
echo E for Exit
echo.
set/p "auth="
if %auth%==Y goto data
if %auth%==y goto data
if %auth%==N goto back
if %auth%==n goto back
if %auth%==E goto end
if %auth%==e goto end
echo.
echo Wrong Input
goto top

:data
cls
echo.
echo  Enter your data in the file (text only)
set/p "data="
cls
:sec
echo.
echo  Write File %loc%\%file%? (Y/N)
set/p "ask="
if %ask%==Y goto make
if %ask%==y goto make
if %ask%==N goto back
if %ask%==n goto back
echo.
echo Wrong Input
goto sec

:make
echo.
echo %data% >> "%loc%\%file%
cls
echo.
echo  File Created.....
pause
cls

:doyou
echo.
echo  Do you want to create another file? (Y/N)
set/p "aga="
if %aga%==Y goto back
if %aga%==y goto back
if %aga%==N goto end
if %aga%==n goto end
echo.
echo Wrong Input
goto doyou

:end
exit

Copy and paste it in Notepad and save it as anything.bat

To use it open it, enter location where you want to make the file.
P.S.- Do not enter "\" at the end of the location

Next enter the filename with it's extension

Enter the data and enter Y to create the file.

Enjoy

No comments:

Post a Comment