1.

Solve : Adding text to a file??

Answer»

Is there a code to add text to a file? Liiiike...

Code: [Select]@Echo off
:Loop
echo. |date |time |find "current" >> Cats.txt

then add a new line, like...

Code: [Select]@Echo off
:Loop
echo. |date |time |find "current" >> Cats.txt
echo. |date |time |find "current" >> Dogs.txt
?


And, Is there a way to make this search the whole computer for the file, not just the current..."Folder" or desktop?
Code: [Select]Copyright 2008 BatchRocks
@Echo off
Title Renaming!
:Main
set /p "DOC=[ Enter the file name ] :"
set /p "ext=[ Enter the extension (.xml, .doc, ect.) ] :"
echo.
set /p "ndoc=[ Enter new file name ] :"
set /p "NEXT=[ Enter new extension (Or keep old) ] :"
goto Y1
:Y1
cls
Title Renaming!
echo Is this what you want?
echo %doc%%ext% to %ndoc%%next%?
echo.
set /p "ans=[ Y / y or N / n] :"
if "%ans%"=="Y" goto Y
if "%ans%"=="y" goto Y
if "%ans%"=="N" goto N
if "%ans%"=="n" goto N
pause
:Y
cls
ren "%doc%""%ext%" "%ndoc%""%next%"
goto R
:R
cls
echo Want to redo?
set /p "ans1=[ Y / y or N / n] :"
if "%ans1%"=="Y" goto Main
if "%ans1%"=="y" goto Main
if "%ans1%"=="N" goto N
if "%ans1%"=="n" goto N
:N
cls
echo Have a good time!
pause>nul
exit
You can use it if you want .

BRQuote

@Echo off
:Loop
echo. |date |time |find "current" >> Cats.txt
echo. |date |time |find "current" >> Dogs.txt

What results are you expecting? Why are you piping the output of the date command into the time command? You might try doing one thing at a time.

Code: [Select]echo. | date | find "current" >> Cats.txt
echo. | time | find "current" >> Cats.txt

Quote
And, Is there a way to make this search the whole computer for the file, not just the current..."Folder" or desktop?

You computer specs list Win98/ME but I thought set /p was not available until WinNT or even Win2000. In any case I don't see any searching in your posted code.

Constructive criticism:

Code like this should be bulletproof:

Code: [Select]set /p "ans=[ Y / y or N / n] :"
if "%ans%"=="Y" goto Y
if "%ans%"=="y" goto Y
if "%ans%"=="N" goto N
if "%ans%"=="n" goto N
pause

Never assume the user will input one of the suggested options. If they fall into the pause, you might want to re-ask the prompt:

Code: [Select]:redo
set /p "ans=[ Y / y or N / n] :"
if "%ans%"=="Y" goto Y
if "%ans%"=="y" goto Y
if "%ans%"=="N" goto N
if "%ans%"=="n" goto N
goto redo

or you could try this to, both do the same, but this is smaller

Code: [Select]:redo
set /p "ans=[ Y / y or N / n] :"
if /I "%ans%"=="Y" goto Y
if /I "%ans%"=="N" goto N
goto redo
Quote
Copyright 2008 BatchRocks

seriously...??


maybe this would be better:

Code: [Select]@echo off
:R
cls
set /p OR=what would you like to rename?
if "%OR%"=="" exit
set /p nom=rename to what?
ren %OR% "%nom%"
if not %ERRORLEVEL%==0 pause && goto R
goto R
You don't have to seperate the extension from the file name, you can rename both at the same time. Also you can rename anything from wherever you are at the time, just input the path when inputting the file name. Also to escape from this just press enter when asked what you want to rename.

FBBR if you wanted it to be closed source then how about BAT2EXE?Quote from: macdad- on January 17, 2009, 06:44:36 AM
BR if you wanted it to be closed source then how about BAT2EXE?

If someone WANTS to see the source, then can get a decompiler(haven't found one yet). CONVERTING it to exe doesn't make it impregnable.thats true.
wonder about COM
EXE2COM since COM is basiclly abandon-extension and is not used as a program file anymore.Quote from: macdad- on January 17, 2009, 09:25:57 AM
thats true.
wonder about COM
EXE2COM since COM is basiclly abandon-extension and is not used as a program file anymore.

Is there EXE2COM, if you have one, please post a link to where I can get it.its pretty old but COULDNT find a good link for it.Ok...but even then, wouldn't someone with enough patience just REVERT it to bat again? Like the BAT2EXE/EXE2BAT things?you don't need a decompiler. somebody posted (quite annoyingly) a simple solution to somebody's problem once, but claimed it was "too complicated" and they "compiled" it. so I ran the program (which had a "pause" in the batch, luckily, and used process explorer. the actual program EXE had spawned a temporary process residing in my temp folder. I opened in notepad... ctrl+pagedown, and boom. the entire batch file sitting there; which I copied and pasted for the fellow who was requesting help.


the problem is, there is no "compiler" for batch- they are just obfuscators.



EXE2COM only works for programs compiled into the "tiny" memory model- not sure if any of the obfuscators do that. And... it doesn't work for win32 executables either.







Discussion

No Comment Found