Talking batch AI (that learns) but I have one issue - batch-file

When i use it, it will only speak when i teach it another word, i can't get it to speak a specific answer in the directory, do you guys have any opinions on how to go about fixing this, i'm stumped..
#ECHO OFF
#mode con cols=55 lines=10
if not exist data.txt echo.>data.txt
:begin
set /p text="Talk: "
for /f "tokens=1,* delims=#" %%i in (data.txt) do (
if /i "%text%"=="%%i" (
echo Visu: %%j
goto begin
)
)
:Learn
echo --- I don't know that.
set /p answer=--- What would be a good answer to '%text%'?
echo %text%#%answer%>>data.txt
echo Visu: thank you
goto Aye
:Aye
echo set speech = Wscript.CreateObject("SAPI.spVoice") >> "temp.vbs"
echo speech.speak "%answer%" >> "temp.vbs"
start temp.vbs
pause
del temp.vbs
goto begin

Make Aye a subroutine/function you can call with the text to speak.
In a called sub the first argument is %1
#ECHO OFF
mode con cols=55 lines=10
if not exist data.txt Type Nul >data.txt
:begin
cls& Echo Talk to Visu
set "text=" & set /p text="Talk: "
if not defined text exit /B
for /f "tokens=1,* delims=#" %%i in (data.txt
) do if /i "%text%"=="%%i" Call :Aye "%%~j" & Goto :begin
:Learn
echo --- I don't know that.
echo --- What would be a good answer to '%text%'
set /p answer=?
echo %text%#%answer%>>data.txt
Call :Aye "%answer%"
goto :begin
:Aye
echo Visu: %~1
echo Visu: thank you
echo set speech = Wscript.CreateObject("SAPI.spVoice") > "temp.vbs"
echo speech.speak "%~1" >> "temp.vbs"
cscript //Nologo temp.vbs
Timeout /T 3 /Nobreak >Nul
del temp.vbs
goto :Eof

replace start temp.vbs with cscript /nologo temp.vbs.
And probably you want
echo set speech = Wscript.CreateObject("SAPI.spVoice") > "temp.vbs"
(> instead of >>) to overwrite the file every time?

Related

Batch How to clear clipboard after get copy from clipboard using CreateObject( htmlfile ) ClipboardData

This question is based on my previous question here .
Major of these below codes are combination from #Hackoo answer(many thanks to Him) and some other users from SO. And I made a very little effort to combine them with other's codes to arrange a simple tutorial board which can :
paste user input(hidden) using number 1 and automatically entered without pressing enter.
typewriting the input with type writer.
read and speak the input.
For now, it is working as intended. The full codes is as follow :
#echo off
title %~nx0
color 0a
setlocal EnableDelayedExpansion
set color_white=%ESC%[37m
set color_black=%ESC%[30m
:menuLOOP
Color 0A & Mode con cols=78 lines=25
echo(
echo( ===============================================================
::set choice=
choice /c 12345 /n /m " "
IF errorlevel 5 goto choice5
IF errorlevel 4 goto choice4
IF errorlevel 3 goto choice3
IF errorlevel 2 goto choice2
IF errorlevel 1 goto choice1
:choice1 INPUT TYpewriter
call :menu_[1]
GOTO:menuLOOP
:choice2 PLAY TYpewriter Audio
call :menu_[2]
GOTO:menuLOOP
:choice3 STOP TYpewriter Audio
call :menu_[3]
GOTO:menuLOOP
:choice4 PLAYLoop TYpewriter Audio
call :menu_[4]
GOTO:menuLOOP
:choice5
call :menu_[5]
GOTO:menuLOOP
::********************************************************************************************
:menu_[1] input
cls
echo:
set SendKeys=CScript //nologo //E:JScript "%~F0"
echo pasteclip= CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text") > temp.vbs
echo WScript.Echo pasteclip >> temp.vbs
cscript //nologo temp.vbs > temp.txt
set color_white=%ESC%[37m
set color_black=%ESC%[30m
REM for /f "Tokens=* Delims=" %%x in (temp.txt) do set SendPaste=%%x
REM set "text=%SendPaste%"%color_black%
set "File2Read=temp.txt"
rem This will read a file into an array of variables and populate it
setlocal EnableExtensions EnableDelayedExpansion
for /f "delims=" %%a in ('Type "%File2Read%"') do (
set /a count+=1
set "Line[!count!]=%%a"
)
rem Display array elements
#For /L %%i in (1,1,%Count%) do (
:: You should call this Call :Typewriter "!Line[%%i]!" inside the loop for /L
Call :Typewriter "!Line[%%i]!"
)
GOTO:menuLOOP
::********************************************************************************************
:menu_[2] Play TYpewriter Audio
cls & color 0A
Call:SkipLine 10
Call:Tab 3
::echo %x% Please Wait for a while .. Launching DJ Buzz Radio ...
Taskkill /IM "wscript.exe" /F >nul 2>&1
Set vbsfile=%temp%\DJBuzzRadio.vbs
Set URL=Typewriter-sound.mp3
Call:Play %URL% %vbsfile%
Start %vbsfile%
TimeOut /T 1 /NoBreak>nul
GOTO:menuLOOP
::********************************************************************************************
:menu_[3] Stop the music
cls & color 0C
Call:SkipLine 10
Call:Tab 3
::echo %x% Please Wait for a while .. Stopping the music ...
Taskkill /IM "wscript.exe" /F >nul 2>&1
TimeOut /T 1 /NoBreak>nul
GOTO:menuLOOP
::********************************************************************************************
:menu_[4] PlayLoop TYpewriter Audio
cls & color 0A
Call:SkipLine 10
Call:Tab 3
::echo %x% Please Wait for a while .. Launching DJ Buzz Radio ...
Taskkill /IM "wscript.exe" /F >nul 2>&1
Set vbsfile=%temp%\DJBuzzRadio.vbs
Set URL=Typewriter-sound.mp3
Call:PlayLoop %URL% %vbsfile%
Start %vbsfile%
TimeOut /T 1 /NoBreak>nul
GOTO:menuLOOP
::********************************************************************************************
::********************************************************************************************
:Play
(
echo Play "%~1"
echo Sub Play(URL^)
echo Dim Sound
echo Set Sound = CreateObject("WMPlayer.OCX"^)
echo Sound.URL = URL
echo Sound.settings.volume = 100
echo Sound.Controls.play
echo do while Sound.currentmedia.duration = 0
echo wscript.sleep 100
echo loop
echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000
echo End Sub
)>%~2
::*********************************************************************************************
::********************************************************************************************
:PlayLoop
(
echo Play "%~1"
echo Sub Play(URL^)
echo Dim Sound
echo Set Sound = CreateObject("WMPlayer.OCX"^)
echo Sound.URL = URL
echo Sound.settings.volume = 100
echo Sound.settings.setMode "loop", True
echo Sound.Controls.play
echo While Sound.playState ^<^> 1
echo WScript.Sleep 100
echo Wend
echo End Sub
)>%~2
::*********************************************************************************************
::*********************************************************************************************
:Tab
set "x="
For /L %%I In (1,1,%1) Do Set "x=!x! "
REM ^-- this is a TAB
goto :eof
::*********************************************************************************************
:SkipLine
For /L %%I In (1,1,%1) Do Echo(
Goto:Eof
:EOF
EXIT
::*********************************************************************************************
::*********************************************************************
:TypeWriter
Cls
echo(
(
echo strText=wscript.arguments(0^)
echo intTextLen = Len(strText^)
echo intPause = 150
echo For x = 1 to intTextLen
echo strTempText = Mid(strText,x,1^)
echo WScript.StdOut.Write strTempText
echo WScript.Sleep intPause
echo Next
echo Set Voice=CreateObject("SAPI.SpVoice"^)
echo voice.speak strText
)>%tmp%\%~n0.vbs
#cScript.EXE /noLogo "%tmp%\%~n0.vbs" ^" ^
%empty line%
^
%empty line%
%~1^"
exit /b
::*********************************************************************
:: Most helpful references to arrange this batch:
::https://stackoverflow.com/questions/28369536/batch-file-typewriter-effect
::https://stackoverflow.com/questions/664957/can-i-mask-an-input-text-in-a-bat-file?lq=1
::https://stackoverflow.com/a/63847096/9222942 mask with black
::https://stackoverflow.com/a/24792070/9222942 can-i-mask-an-input-text-in-a-bat-file
::https://stackoverflow.com/a/62121081/9222942 how-can-you-get-the-clipboard-contents-with-a-windows-command
::https://stackoverflow.com/a/31880899/9222942 how-to-play-invisible-music-in-a-batch-file
::https://stackoverflow.com/a/21205537/9222942 automatically-accept-user-input-windows-batch
::https://stackoverflow.com/a/16116676/9222942%20how-to-read-file-contents-into-a-variable-in-a-batch-file
But a problem is that, this batch store every clipboard beginning from running the first command 1.
Let say, for the first time i copied sentence 1 with text "Summarize the problem".
After running the batch, by pressing 1 , the input sentence 1 should then be typewritten to cmd.
Then when i copied sentence 2 with text let say "describe what you've tried" , it will repeat the sentence 1 , and only after finishing the sentence 1 it will write sentence 2.
Even when I do copy for the third time, the forth, it will also repeat from the very first clipboard(i.e sentece 1, sentence 2 and so on)
My question is, how to stop the repeatation of the first clipboard sentence?
I've tried manually delete the temp.txt and the temp.vbs after running the first command but didnt help.
Also i've tried using cmd /c “echo off | clip” which is from here .
I've applied it as follow :
#For /L %%i in (1,1,%Count%) do (
:: You should call this Call :Typewriter "!Line[%%i]!" inside the loop for /L
Call :Typewriter "!Line[%%i]!"
cmd.exe /c echo.|clip
)
, but also didnt work.
Could someone please help on how to clear the the repeatation?
As instructed by Sir Stephan(all credit goes to Him), all i need to do is add set "Count=0" before the 1st for loop that counts the lines :
setlocal EnableExtensions EnableDelayedExpansion
set "Count=0"
for /f "delims=" %%a in ('Type "%File2Read%"') do (
set /a count+=1
set "Line[!count!]=%%a"
)
rem Display array elements
#For /L %%i in (1,1,%Count%) do (
:: You should call this Call :Typewriter "!Line[%%i]!" inside the loop for /L
Call :Typewriter "!Line[%%i]!"

How do i make the vbs file to work properly?

When i tried to create a vbs file with batch, this line doesn't show in the vbs file
echo WScript.Sleep 2000 : Objshell.Run "taskkill /f /im cmd.exe", 0 >> 2.vbs
What do i need to escape or something to make the vbs file runnable ?
Thanks!
I made a new batch code to make life easier for users in order to integrate some vbs files that will be generated automatically with a batch file when we execute it.
This batch code is based on search and replace using Regex with vbscript.
So, the user can just drag and drop a vbscript over this batch script. And voila !
#echo off
Title Vbs2Bat Intergration using Regex with vbscript by Hackoo 2020
Set "InputFile=%~1"
If ["%InputFile%"] EQU [""] Goto :Help
Set "TempFile=%Temp%\%~n1.tmp"
Set "OutPutFile=%~dpn1_.txt"
Call :Search_Replace "%InputFile%" "%TempFile%"
REM ------------------------Generate the formatted file------------------------------
> "%OutPutFile%" (
echo #echo off
echo Call :Generate_VBS_File
echo Call :Execute_VBS_File
echo REM -----------------------------------------------------------------------------
echo :Generate_VBS_File
echo ^>"%%tmp%%\%%~n0.vbs" (
)
>> "%OutPutFile%" (#for /f "tokens=* delims=" %%a in ('Type "%TempFile%"') do echo. echo %%a)
>> "%OutPutFile%" (
echo ^)
echo Exit /B
echo REM -----------------------------------------------------------------------------
echo :Execute_VBS_File
echo cscript //nologo "%%tmp%%\%%~n0.vbs"
echo If Exist "%%tmp%%\%%~n0.vbs" Del "%%tmp%%\%%~n0.vbs"
echo Exit /B
echo REM -----------------------------------------------------------------------------
)
REM ---------------------------------------------------------------------------------
If Exist "%TempFile%" Del "%TempFile%"
If Exist "%OutPutFile%" Start "" "%OutPutFile%" & Exit
::-----------------------------------------------------------------------------------
:Search_Replace <InputFile> <OutPutFile>
(
echo WScript.StdOut.WriteLine Search_Replace(Data^)
echo Function Search_Replace(Data^)
echo Dim strPattern, strReplace, strResult,oRegExp
echo Data = "%~1"
echo Data = WScript.StdIn.ReadAll
echo Set oRegExp = New RegExp
echo oRegExp.Global = True
echo oRegExp.Multiline = True
echo oRegExp.IgnoreCase = True
echo strPattern1 = "[)&<|>]"
echo oRegExp.Pattern = strPattern1
echo strReplace1 = "^$+"
echo strResult1 = oRegExp.Replace(Data,strReplace1^)
echo strPattern2 = "[%%]"
echo oRegExp.Pattern = strPattern2
echo strReplace2 = "%%$+"
echo strResult2 = oRegExp.Replace(strResult1,strReplace2^)
echo Search_Replace = strResult2
echo End Function
)>"%tmp%\%~n0.vbs"
cscript //nologo "%tmp%\%~n0.vbs" < "%~1" > "%~2"
If Exist "%tmp%\%~n0.vbs" Del "%tmp%\%~n0.vbs"
Exit /B
::----------------------------------------------------------------------------------
:Help
Mode 70,4 & Color 0C
echo(
echo You should drag and drop a VBS file over,
echo this script "%~nx0" to be converted !
Timeout /T 10 /NoBreak>nul
Exit
::----------------------------------------------------------------------------------

Pinging Multiple PCs and Adding Text

I'm pretty new to this so please bear with me, and if you require anymore information from me please say. Thanks in advance for your help.
I have this code that pings different PCs then returns back if they are online/offline. I wanted to know if you could add another column once the bat file has ran its ping test so it has the computer name next to it.
#echo off
if exist C:\tools\computers.txt goto Label1
echo.
echo Cannot find C:\tools\computers.txt
echo.
Pause
goto :eof
:Label1
echo PingTest executed on %date% at %time% > C:\tools\z.txt
echo ================================================= >> C:\tools\z.txt
for /f %%i in (C:\tools\computers.txt) do call :Sub %%i notepad C:\tools\z.txt
goto :eof
:Sub
echo Testing %1 set state=alive ping -n 1 %1 | find /i "bytes=" || set state=dead echo %1 is %state% >> C:\tools\z.txt
The bat file creates a document that shows the following;
PingTest executed on 28/07/2016 at 13:10:28
99.1.82.28 is alive
99.1.82.100 is alive
ect.
If possible I would like the bat file to run so it displays this;
The bat file creates a document that shows the following;
PingTest executed on 28/07/2016 at 13:10:28
Computer 1 : 99.1.82.28 is alive
Computer 2 : 99.1.82.100 is alive
ect.
--
Would appreciate any help & guidance on this.
Thanks.
You can try this solution :
#echo off
Title Ping Test
set "URLS=URLS.txt"
set "LogFile=PingResults.txt"
If exist %LogFile% Del %LogFile%
(
echo ******************************************************
echo PingTest executed on %Date% # Time %Time%
echo ******************************************************
echo(
) > %LogFile%
Setlocal EnableDelayedExpansion
for /f "usebackq delims=" %%a in ("%URLS%") do (
for /f "tokens=2 delims=[]" %%b in ('ping -n 1 %%a') do set "ip=%%b"
ping -n 1 %%a>nul && set "msg=%%a : !ip! ALive ok" || set "msg=%%a : !ip! Dead failed to respond"
echo !msg!
echo !msg! >> %LogFile%
)
)
EndLocal
Start "" %LogFile%
pause>nul & exit
EDIT : on 29/07/2016 # 12:48
Another version with multi-colors : Special thanks goes to ICARUS for the color function (-_°)
#echo off
Rem Special thanks goes to Iracus for the color function (-_°)
mode con cols=60 lines=20
Title Multi-Ping hosts Tester with Multi-colors by Hackoo
set "URLS=URLS.txt"
set "LogFile=PingResults.txt"
If exist %LogFile% Del %LogFile%
call :init
echo(
call :color 0E "------- Ping Status of Computers hosts -------" 1
echo(
(
echo ******************************************************
echo PingTest executed on %Date% # Time %Time%
echo ******************************************************
echo(
) > %LogFile%
Setlocal EnableDelayedExpansion
for /f "usebackq delims=" %%a in ("%URLS%") do (
for /f "tokens=2 delims=[]" %%b in ('ping -n 1 %%a') do set "ip=%%b"
ping -n 1 %%a>nul && set "msg=%%a - !ip! ALive ok" && Call :Color 0A "!msg!" 1 || set "msg=%%a - !ip! Dead failed to respond" && Call :Color 0C "!msg!" 1
echo !msg! >> %LogFile%
)
)
EndLocal
Start "" %LogFile%
pause>nul & exit
:init
prompt $g
for /F "delims=." %%a in ('"prompt $H. & for %%b in (1) do rem"') do set "BS=%%a"
exit /b
:color
set nL=%3
if not defined nL echo requires third argument & pause > nul & goto :eof
if %3 == 0 (
<nul set /p ".=%bs%">%2 & findstr /v /a:%1 /r "^$" %2 nul & del %2 2>&1 & goto :eof
) else if %3 == 1 (
echo %bs%>%2 & findstr /v /a:%1 /r "^$" %2 nul & del %2 2>&1 & goto :eof
)
exit /b
EDIT : Update On 23/08/2016
http://pastebin.com/zjYwSqUM

after compiling a batch file to exe it stops working

I'm writing a small folder locking software. Recently a masking function was integrated, so that the password input is masked. When in a bat file the program works perfectly, however after compiling the program stops working. The problem ,I think, lies in the "masking" code, as it starts an endless loop and masks every input, even the "Enter" stroke, thus preventing the program from further executing. I even tried iexpress, but it also gives an Error, namely:
Error creating process Command.com/c
C:\Users...\AppData\Local\Temp\IXP000.TMP\Folder~1.BAT
Can someone please double check my code and tell me what is wrong, as I am still learning and could not figure out how to fix it.
Thanks in advance.
#Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
mode con cols=80 lines=25
color 5F
title Folder Locker by KBKOZLEV
:SETPASS
set "tipp="
set "password="
if exist "password.txt" (
set /p password=<password.txt
attrib +h +s "password.txt"
)
if exist "tipp.txt" (
set /p tipp=<tipp.txt
attrib +h +s "tipp.txt"
)
:START
if exist "Locked" goto :OPEN
if exist "Unlocked" goto :LOCK
if not exist "Unlocked" goto :MDLOCKER
:LOCK
ren "Unlocked" "Locked"
attrib +h +s "Locked"
echo(
echo Folder locked.
CHOICE /C X /T 1 /D X > nul
goto :END
exit
:MDLOCKER
md "Unlocked"
echo>password.txt 1234
echo>tipp.txt 1234
attrib +h +s "password.txt"
attrib +h +s "tipp.txt"
cls
echo(
echo Private folder created successfully.
CHOICE /C X /T 1 /D X > nul
goto :END
:OPEN
color 2F
cls
echo ********************************************************************************
echo Folder Locker by KBKOZLEV v.01
echo.
echo ********************************************************************************
echo ---- Enter password to unlock folder, or enter "new" to set a new password. ----
echo --------------------------------------------------------------------------------
echo.
echo Password tipp: %tipp%
echo(
set "pass="
rem set /p "pass=Password: "
Set /P "=Password:" < Nul
Call :PasswordInput pass
if /i "%pass%"=="new" goto :NEWPASS
if "%pass%"=="%password%" (
attrib -h -s "Locked"
ren "Locked" "Unlocked"
echo(
echo Folder unlocked successfully.
goto :END
)
goto :FAIL
:FAIL
color 4F
cls
echo(
echo Invalid password, please try again.
CHOICE /C X /T 1 /D X > nul
cls
goto :OPEN
:NEWPASS
color 8F
cls
echo(
set "oldpass="
rem set /p "oldpass=Old password: "
Set /P "=Old Password:" < Nul
Call :PasswordInput oldpass
if not "%oldpass%"=="%password%" goto :FAIL
:ENTERNEW
color 8F
cls
echo(
set "newpass=""
rem set /p "newpass=New password: "
Set /P "=New Password:" < Nul
Call :PasswordInput newpass
set newpass=%newpass:"=%
if "%newpass%"=="" (
echo(
echo Invalid new password, please enter new password again.
CHOICE /C X /T 1 /D X > nul
goto :ENTERNEW
)
if exist "password.txt" attrib -h -s "password.txt"
echo>password.txt %newpass%
echo(
set "passtipp=""
set /p "passtipp=New tipp: "
set passtipp=%passtipp:"=%
if exist "tipp.txt" attrib -h -s "tipp.txt"
if not "%passtipp%"=="" (
echo>tipp.txt %passtipp%
) else (
del "tipp.txt"
)
goto :SETPASS
:END
color
EndLocal
Goto :Eof
:PasswordInput
::Author: Carlos Montiers Aguilera
::Last updated: 20150401. Created: 20150401.
::Set in variable Line a input password
::
::Update 20150503: http://stackoverflow.com/users/3439404/josefz?tab=profile
::Changes made in next lines:
:: SetLocal EnableDelayedExpansion
:: If !CHR!==!CR! Echo(&EndLocal&set "%1=%Line%"&Goto :Eof
::Usage:
:: Call :PasswordInput variableName
::where variableName is a name of output variable (by reference call)
::
SetLocal EnableDelayedExpansion
For /F skip^=1^ delims^=^ eol^= %%# in (
'"Echo(|Replace.exe "%~f0" . /U /W"') Do Set "CR=%%#"
For /F %%# In (
'"Prompt $H &For %%_ In (_) Do Rem"') Do Set "BS=%%#"
Set "Line="
:_PasswordInput_Kbd
Set "CHR=" & For /F skip^=1^ delims^=^ eol^= %%# in (
'Replace.exe "%~f0" . /U /W') Do Set "CHR=%%#"
If !CHR!==!CR! Echo(&EndLocal&set "%1=%Line%"&Goto :Eof
If !CHR!==!BS! (If Defined Line (Set /P "=!BS! !BS!" <Nul
Set "Line=!Line:~0,-1!"
)
) Else (Set /P "=*" <Nul
If !CHR!==! (Set "Line=!Line!^!"
) Else Set "Line=!Line!!CHR!"
)
Goto :_PasswordInput_Kbd
You are executing the 16 bit command.com (only in Win 32) not the 32 or 64 bit cmd.exe. It doesn't suport brackets, long filenames, or set /p.
It also doesn't support long file names.

How to do while loop in windows batch

I wrote a windows batch script to check and move files to another directory based on the list I put in a notepad file named list.txt. But I have no idea that how to set the while-loop. Only to jump out of the subroute when the condition fulfill.
In C Programming, we could write like this by setting a while-loop direcly. But seems in windows batch is quite different.
All I want is like this:
Directory A:
1. A.txt
2. B.txt
3. list.txt (By line sequential with filename want to move)
4. process.bat
Directory B:
None of files (Then move a file by order of line set in list.txt) OR
A.txt (If already existed a text file in directory, process.bat will pause before A.txt disappear)
Process.bat
#echo off
:readline
for /f "tokens=*" %%a in (list.txt) do call :processline %%a
goto :eof
:processline
if exist D:\DirectoryA\*.txt (
echo %time% >> D:\AutoLog\Log.txt
echo Previous job did not finished yet. >> D:\AutoLog\Log.txt
Timeout /t 30
echo.
)
set name=%*
if exist %name%.txt (
echo %time% >> D:\AutoLog\Log.txt
echo File found and processing %name%.txt now... >> D:\AutoLog\Log.txt
copy "%~dp0\%name%.txt" "D:\DirectoryB"
echo Transfer %name%.txt completed!! >> D:\AutoLog\Log.txt
echo. >> D:\AutoLog\Log.txt
Timeout /t 790
echo.
echo ==============================================================
)
:eof
Please guide me to finish the script by using a while-loop method. Thanks
I change some script sequence and it works now.
#echo off
:readline
for /f "tokens=*" %%a in (list.txt) do call :processline %%a
goto :eof
:processline
set name=%*
if exist C:\Test2\*.txt (
echo %date% %time% >> C:\Test2\Log.txt
echo Previous job did not finished yet. >> C:\Test2\Log.txt
Timeout /t 5
echo.
echo. >> C:\Test2\Log.txt
goto :processline
)
if exist %name%.txt (
echo %date% %time% >> C:\Test2\Log.txt
echo File found and processing %name%.txt now... >> C:\Test2\Log.txt
copy "%~dp0\%name%.txt" "C:\Test2"
echo Transfer %name%.txt completed!! >> C:\Test2\Log.txt
echo. >> C:\Test2\Log.txt
Timeout /t 10
echo.
echo ==============================================================
)
:eof
This will copy as well as count the number of lines from your text file..
# echo off
:TextPath
cls
set /p Input=#1 Enter the full path of the text file :
set /p Source=#2 Enter the full path of Source :
set /p Target=#3 Enter the full path of Destination :
:choice
set /P c=Ready to Continue[Y/N]?
if /I "%c%" EQU "Y" goto :Yes
if /I "%c%" EQU "N" goto :No
goto :choice
:Yes_Local
for /f "delims=" %%i in (%Input%) do echo f| xcopy /f /y "%Source%\%%i" "%Target%\%%i"
for /f %%C in ('Find /V /C "" ^< %Input%') do set Count=%%C
msg * No of Lines executed= %Count%
exit
:No
cls
color e
echo Redirecting to Main....
PING 127.0.0.1 -n 2 >NUL
cls
echo Please wait
PING 127.0.0.1 -n 4 >NUL
goto TextPath

Resources