2014-01-22 51 views
0

所以我試圖做一個bat文件,你首先輸入你想要的文本文件名然後你可以在你寫完一個句子之後寫出一個文件,然後如果你想繼續或不,但我一直卡住從這些問題到變量的每一件事試圖寫一個批次的東西

我還需要幫助創建和命名文件。

@echo off 
title textfilewriter 
color a9 
echo where do you want your new file? 
set /p c=input here: 
cls 
echo what should it be named? 
set /p d=input here: 
:start 
echo input text and it will go to desierd txt file 
set /p a=input here: 
>>%c%.txt echo %rfn% 
echo input watch and it will bring upp your text file 
set /p b=input here: 
goto start 
if %b%==watch goto watch 
:watch 
start /wait text.txt 
cls 
goto start 
:reload 
start textfilewriter.bat 
exit 

我知道它不是在所有但做爲什麼我尋求幫助,如果有一個人有時間幫我

啓動/等待的text.txt <

和那些無法正常工作的東西 我會真的很感激它,我很抱歉所有壞英語...

回答

1

它可能會失敗一堆原因(不檢查目錄是否存在,如果文件是可寫的,如果輸入關鍵字符,......),但它是一個骨架。

@echo off 
    setlocal enableextensions 

    title textfilewriter 
    color a9 

:start 

    cls 

    set "where=" 
    set /p "where=where do you want your new file?" 
    if "%where%"=="" goto endProcess 

    set "file=" 
    set /p "file=what should it be named?" 
    if "%file%"=="" goto start 

:info 
    echo. 
    echo input text and it will go to the desired txt file 
    echo. 
    echo input "start" for a new file, "watch" to see saved text or "end" to exit 
    echo. 

:getLine 
    set "line=" 
    set /p "line=text? :" 

    if /i "%line%"=="start" goto start 
    if /i "%line%"=="end" goto endProcess 
    if /i "%line%"=="watch" goto dumpFile 

    >>"%where%\%file%.txt" echo %line% 
    goto getLine 

:dumpFile 
    echo. 
    type "%where%\%file%.txt" 
    echo. 
    goto info 

:endProcess 
    endlocal 
    exit /b 
+0

非常感謝你:) – user3108088