China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-19 22:00
中国DOS联盟论坛 » 网络日志(Blog) » 523066680 Editing Area View 33,498 Replies 42
Floor 16 Posted 2009-08-23 07:19 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
```cpp
#include <Conio.h>
#include <graphics.h>
#include <stdlib.h>
#define closegr closegraph
#define NDOT 3


typedef struct
{
int a, b, x, y;
} DotInf;


void initgr(void) /* BGI initialization */
{
int gd = DETECT, gm = 0;
registerbgidriver(EGAVGA_driver);
initgraph(&gd, &gm, "");
}

void delta(DotInf dot, int c)
{
int i, j;
setcolor(c);
for (i = 0; i < NDOT; i++)
for (j = i + 1; j < NDOT; j++)
{
line(dot.x, dot.y, dot.x, dot.y);
}
}

int main(void)
{
int i, j, whi = 0, edotn = 0;
DotInf snk;
DotInf edot;
for (i = 0; i < 9; i++)
for (j = 0; j < NDOT - 1; j++)
{
edot.x = edot.y = 0;
}

initgr(); /* BGI initialization */

for (i = 0; i < NDOT; i++)
{
snk.a = snk.b = snk.x = snk.y = 200;
edot.x = edot.y = 200;
}
randomize();
while (!kbhit())
{
if (edotn < 9)
edotn++;
else
edotn = 0;
if (whi < NDOT)
whi++;
else
whi = 0;
for (i = 0; i < 400; i++)
delay(15);
if (edot.x != 0)
delta(edot, 0);
delta(snk, 2);

for (i = 0; i < NDOT; i++)
{
if ((snk.x == snk.a) && (snk.y == snk.b))
{
snk.a = rand() % 600 + 1;
snk.b = rand() % 400 + 20;
}
}
for (i = 0; i < NDOT; i++)
{
if (whi > i)
continue;
if (snk.x > snk.a)
snk.x--;
else if (snk.x < snk.a)
snk.x++;
else
{
if (snk.y > snk.b)
snk.y--;
else if (snk.y < snk.b)
snk.y++;
}

edot.x = snk.x;
edot.y = snk.y;

}


}

getch();
closegr(); /* Restore TEXT screen mode */
return 0;
}
```
Floor 17 Posted 2009-08-23 07:20 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
```
@echo off
setlocal enabledelayedexpansion
mode con cols=25 lines=5
title %date%
set "str=xxxxxxxx"
:a
set t=%time:~0,8%
call :next
ping -n 3 127.1>nul
set "t= "
call :next
goto :a

:next
for /l %%a in (0,1,7) do (set num%%a=%%a)
set /a aa=8
:aa
set /a rand=%random%%%aa,aa-=1
set /a x=num%rand%,xb=x+1
set str=!str:~0,%x%!!t:~%x%,1!!str:~%xb%!
set num%rand%=!num%aa%!
ping -n 1 127.1>nul
cls
echo, %str%
if %aa% gtr 0 (goto :aa)
goto :eof
```

[ Last edited by 523066680 on 2009-8-23 at 07:22 ]
Floor 18 Posted 2009-09-03 09:11 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Decompose a natural number into n consecutive natural numbers.

```batch
@echo off
:a
set "inp="
set /p inp="input a number: "
set /a act=2,end=inp/2,inp*=10,the500=1,the001=1
:lp
set /a x=inp/act,xx=inp%%act,xxx=act%%2
if defined the%x:~-1%%xx%%xxx% (call :func %x:~-1%)
if %act% lss %end% (set /a act+=1 &goto :lp)
pause &goto :a

:func
set /a a=(x-%1)/10-(act-1)/2,b=(x+%1)/10+(act-1)/2
if %a% lss 0 (set /a end=0 &goto :eof)
for /l %%a in (%a%,1,%b%) do set /p= %%a<nul
echo,&echo, &goto :eof
```

Numbers with negative numbers in the composition:

```batch
@echo off
:a
set /p inp="input a number: "
set /a act=2,end=inp/2,inp*=10,the500=1,the001=1
:lp
set /a x=inp/act,xx=inp%%act,xxx=act%%2
if defined the%x:~-1%%xx%%xxx% (call :func %x:~-1%)
if %act% lss %end% (set /a act+=1 &goto :lp)
pause &set "inp=" &goto :a

:func
set /a a=(x-%1)/10-(act-1)/2,b=(x+%1)/10+(act-1)/2
for /l %%a in (%a%,1,%b%) do set /p= %%a<nul
echo,&echo, &goto :eof
```

List numbers around 1000 that cannot be split into n consecutive natural numbers:

```batch
@echo off
set /a inp=0,the500=1,the001=1
:a
set /a inp+=1,act=2,end=inp/2,inp*=10,have=0
:lp
set /a x=inp/act,xx=inp%%act,xxx=act%%2
if defined the%x:~-1%%xx%%xxx% (set /a inp/=10 &goto :a)
if %act% lss %end% (set /a act+=1 &goto :lp)
set /a inp/=10
echo,%inp%
if %inp% lss 1000 goto :a
pause
```
Floor 19 Posted 2009-09-15 22:30 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
```vbscript
set wsx=createobject("wscript.shell")
if wscript.arguments.count = 0 then
wsx.run "cmd /c cscript " &wscript.scriptname & " 1 &pause>nul"
wscript.quit
end if

checkfile="test1.vbs"
argu=""
set start=wsx.exec("cscript " &checkfile &argu)
set errinfo=start.stderr
set echo=wscript.stdout

x=errinfo.readline

if x="" then
echo.writeline "No error information."
else
str=""
echo.writeline ""
t1=split(x,",")
tt1=split(t1(0),"(")
tt2=split(t1(1),")")
y=tt1(1) : x=tt2(0)
for i = 2 to x
str=str & " "
next
echo.writeline "Filename: " & tt1(0)
echo.writeline "ErrInfo : " & tt2(1)
echo.writeline "(Lines = " &y &" , cols =" &x & ")"
echo.writeline str & "↓"

set readx=createobject("scripting.filesystemobject").opentextfile(checkfile,1)
for i = 2 to y
readx.readline
next
echo.writeline readx.readline
if readx.atendofstream then
echo.writeline "Check Info: End of line."
else
for i = 1 to 4
if readx.atendofstream = false then
echo.writeline readx.readline
end if
next
end if
read.xclose
end if

echo.write vbcrlf &"Press any key to continue..."
echo.close
wscript.quit
```
Floor 20 Posted 2009-11-20 20:09 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Today is very boring...
@echo off
setlocal enabledelayedexpansion
for /l %%a in (1,1,40) do (set spc= !spc!)
set strx=%spc: =x%
for /l %%a in (1,1,20) do (set ln%%a=%spc%)
set /a a=-20
:a
set inp=%a:-=%
set /a n=inp*2,stra=(80-n)/2,la=(24-inp)/2,a+=2
for /l %%a in (1,1,1) do (ping -n 1 127.1>nul)
cls
for /l %%a in (1,1,%la%) do (echo, )
for /l %%a in (1,1,%inp%) do (echo,!spc:~-%stra%!!strx:~-%n%!)
if %a% geq 20 set a=-20
goto :a
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
vsbat +1 2009-12-10 15:27
Floor 21 Posted 2010-01-06 19:34 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
read
Text: 523066680
First one today.
It can be regarded as a kind of note, just like a log
Not really sharing, because everyone will go through their own exploration process.

By the way, learn English, so I pull up the original help together

Parameters and corresponding examples:
-a array assign the words read to sequential indices of the array
variable ARRAY, starting at zero
Assign the input content to the sequential indices of the array according to the delimiter (space or tab, etc.), and consecutive spaces are also counted as 1 division.
After input, the array specification is the same as in C language, and it is expressed in the format of var, with subscripts starting from 0.
Directly echo $var is equivalent to echo ${var}
When echoing an array with subscripts, remember to add {} to express, for example, echo ${a}
Define array variable: read -a arr is okay; read -a arr is wrong.
But you can directly read arr, which is to directly assign a certain element of the array.

-d delim continue until the first character of DELIM is read, rather
than newline
That is, read input until the first character of DELIM is read, instead of ending with a newline. Of course, the "certain character" is not counted.
Test results:
1. After specifying a certain character, the carriage return is also read in, and it will not end due to the carriage return
(Hehe, I haven't tried to end with the carriage return character, I won't make + redundant)
2. -dstr does not reach the end of str, it is the end of s, so people say it is a character
3. -dx str ;# Turned n lines + input character ; echo $str will not output the newline
To echo "$str" will output the newline.

(The following are directly quoted from the help content if I don't know)
-e use Readline to obtain the line in an interactive shell
I don't know, it seems that the default is to end after reading a line? I will make up for it later when I know.

-i text Use TEXT as the initial text for Readline

-n nchars return after reading NCHARS characters rather than waiting
for a newline
rather than here means: instead of.
Read until the Nth character and then end~ instead of waiting for a new line.
The result is that pressing Enter will end in advance
I feel that the description is not strict. The actual rule is {If newline || the number of characters is n; then end}
(The help of this parameter once made me think that rather than means or)

-p prompt prompt is the meaning of prompt, that is, first display the "prompt" string, and then wait for you to input.
With the prompt option, there is no need to echo the prompt separately.

-r do not allow backslashes to escape any characters
backslash backslash "\";
escape escape; here means: escape
Translation: Do not allow backslashes to escape any characters.

-s do not echo input coming from a terminal
Do not display the characters being input from the terminal. (Just like when entering a password),
To be honest, I can't imagine the connection between -s and this function. Learning it is like reciting.

-t timeout time out and return failure if a complete line of input is
not read withint TIMEOUT seconds. The value of the TMOUT
variable is the default timeout. TIMEOUT may be a
fractional number. If TIMEOUT is 0, read returns success only
if input is available on the specified file descriptor. The
exit status is greater than 128 if the timeout is exceeded
1. If a line of input is not completed (triggering the termination input condition) within timeout seconds, it will time out and exit + the command will return an
error code.
2. I can't see this sentence, but executing TMOUT=1, the command line exits after 1 second
3. The value of timeout can be a fractional number , of course, it is not really expressed in fractional notation
It is to tell you that you can use a non-integer, such as -t0.5 is to limit input within half a second.
4. If timeout is set to 0, it will only return success if input is available from the effective special file descriptor.
5. exceed exceed; if timed out, the exit status is greater than 128.
-u fd read from file descriptor FD instead of the standard input
I won't say, I don't know what fd is. Relevant information: http://baike.baidu.com/view/1303430.htm
"Under linux, all operations are on files, and the operations on files are realized by using file descriptors
(file descriptor). In the source code, fd is generally used as the identifier of the file descriptor."


# Still don't know the meanings of several parameters, so I will come back to modify them when I know... #


End: If read is not followed by a variable name, the value will be assigned to the REPLY variable,
However, if you give a new variable name, REPLY will not be updated synchronously.



+++++++++++++++++Learn some English+++++++++++++
#1 -e use Readline to obtain the line in an interactive shell
Baidu search:
obtain obtain; get
Example: He failed to obtain a scholarship. He didn't get a scholarship.

interactive interactive; interactive

#2 -n nchars return after reading NCHARS characters rather than waiting
for a newline

rather than : instead of

#3 -t timeout
time out and return if a complete line of input is
not read withint TIMEOUT seconds. The value of the TMOUT
variable is the default timeout. TIMEOUT may be a
number. If TIMEOUT is 0, read returns success only
if input is available on the specified file descriptor. The
exit status is greater than 128 if the timeout is

failure n. failure
He was doomed to failure. He was doomed to failure

fractional adjective: small amount; fractional

exceed exceed
Floor 22 Posted 2010-01-24 21:46 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Originally, `read -n1` can read only one character, and pressing a key would proceed to the next line.
I wrote a loop with `read -n1`, which is to repeatedly perform this operation by pressing any key, in order to make the loop wait for my confirmation.

As a result, pressing the "right arrow key" caused the loop to run n times in a flash. It turns out that these direction keys, etc., press once and correspond to several characters.
It made me run the loop n times…… (Did it become that a key was pressed n times? O_o)

So I added `read -n9 -t0.1` before `read -n1`, that is:
After reading one character,
within 0.1 seconds, regardless of whether there are 9 characters or not, eat them all
(I thought that `-t0` could instantly eat them, but I found that there was still one key press, and there was a time difference for the several characters that appeared, so I used 0.1)


#!/bin/bash

while true
do
g++ -o wasdq -lglut wasdq.c
./wasdq
echo "Press any key to continue"
read -s -n1 REPLY
read -t0.1 -n9
done

I tried it, and directly using `read -t0.1` to eat characters doesn't work. It only waits for 0.1 seconds and doesn't read characters
(Because by default, the Enter key is used as the end of input)
Logically, it would cause an infinite loop and not wait, but here it only cycled a few times continuously.
Almost forgot, originally there was a `read -n1` in each loop to read one character~.

At the same time, I felt that the `-n` option, when reading n characters, breaks the restriction of ending input with Enter.
`-t -n` is the "OR" restriction~ (timeout)||(when n characters are read) then end
=================================================================
Change it to exit when pressing the q key

#!/bin/bash

while true
do
g++ -o wasdq -lglut wasdq.c
./wasdq
echo "Press any key to continue"
read -s -n1 REPLY
read -t0.1 -n9 other
if ; then exit ;fi
done


[ Last edited by 523066680 on 2010-1-24 at 22:14 ]
Floor 23 Posted 2010-03-14 22:27 ·  中国 广东 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Originally, using xcopy could update the backup directory system to my mobile hard drive. But xcopy only handles copying, so every time I back up, there are additions but no deletions. Although I could first delete everything and then xcopy, which saves code, copying takes more time. So I added a segment of code to delete the things that exist in the backup directory but not in the source directory. Using for combined with dir to traverse the directory tree. Judge if it's a directory, then rd the directory system; if it's a file, then delete (the judgment sentence if exist "%%a\"). But there was an error the first time. The reason was: Some main directories had already been deleted, so the subdirectories and files under them were also deleted, but the directories listed by dir were not updated and still listed their subdirectories, causing the error that subdirectories no longer existed but deletion was still continued. So I added another judgment before each deletion operation: whether the target exists. Features: If the destination disk used for backup doesn't exist, it will exit in advance. If it's executed successfully, a log of deleted files will be generated. Delete first, then xcopy.


@echo off
rem code by 523066680@cn-dos.net
setlocal enabledelayedexpansion
set source=%~dp0
set dest=d:\Burn File Update Area

rem The source path can be its own path. Considering that both input and %~dp0 may have \ at the end,
rem added judgment and processing

if "%source:~-1%"=="\" (set source=%source:~0,-1%)
if "%dest:~-1%"=="\" (set dest=%dest:~0,-1%)

if not exist "%source%\" (
echo The source does not exist, press any key to exit
pause>nul
exit
)

echo Please confirm: Source directory %source%
echo Backup to %dest%
if not exist "%dest%\" (
echo The directory %dest% used as backup does not exist, will try to create.
(md "%dest%")||(
echo The target cannot be created, maybe the target disk does not exist, press any key to exit.
pause>nul
exit
)
goto :justcopy
)

type nul>DelFile.txt
type nul>DelFold.txt

echo _
echo Press any key to start searching + cleaning up the files or subfolders that may be excessive in "%dest%"
pause>nul
echo _

for /f "tokens=*" %%a in ('dir /a /s /b "%dest%"') do (
set pathname=%%a
set pathname=!pathname:%dest%\=!
if exist "%%a" (
if not exist %source%\!pathname! (
if exist "%%a\" (
rd /s /q "%%a"
echo Remove directory : %%a>>DelFold.txt
) else (
del /f /s /a /q "%%a">>DelFile.txt
)
)
)
)
echo This cleanup generates logs DelFold.txt DelFile.txt
type "DelFold.txt" "Delfile.txt"

:justcopy
echo _
echo Press any key to continue starting XCOPY...
pause>nul
echo _
if exist cut.txt (
xcopy /s /d /c /h /exclude:cut.txt "%source%" "%dest%"
) else (
xcopy /s /d /c /h "%source%" "%dest%"
)
echo Press any key to exit
pause>nul
exit


I know some software can achieve this, but the advantage of batch processing is that I can implement some detailed operations by myself, such as the /exclude:cut.txt parameter, which is used to specify the file names or folders listed in the cut.txt text that are not to be copied.

[ Last edited by 523066680 on 2010-3-20 at 12:17 ]
Floor 24 Posted 2010-04-13 11:14 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
```
@echo off
setlocal enabledelayedexpansion
::To reduce the judgment + the name number part is neat (uniform two-digit number), the number of files cannot be greater than 99, that is, 01-99 is specified
::Preliminary verification
if "%~1"=="" (
echo You didn't drag a file onto me, so the first parameter is empty, press any key to bye~
pause>nul
exit
) else (
if exist "%~1" (
echo The folder where the dragged file is located "%~dp1"
echo _
set /p "inp=Before batch renaming, please specify the name prefix:"
set /a n=1
set "nx=000!n!"
set "xformat=%~x1"
set "xpath=%~dp1"
) else (echo There is a parameter but it is not right, bye &pause>nul &exit)
)

::If %~1 is non-empty and exists, it will reach here
:main
if not "%~1"=="" (
if exist "%~1" (
echo The operation being performed: ren "%~nx1" "!inp!!n!%~x1%#"
ren "%~1" "!inp!!nx:~-2!%~x1%#"
set /a n+=1
set nx=000!n!
) else (echo "%~1" is not exist)
shift /1
goto :main
) else (
echo Now restore the format ren "%xpath%*%xformat%#" "*%xformat%"
ren "%xpath%*%xformat%#" "*%xformat%"
pause
exit
)
```
Floor 25 Posted 2010-04-13 15:30 ·  中国 北京 电信
初级用户
★★
Credits 90
Posts 57
Joined 2010-04-12 13:29
16-year member
UID 164386
Gender Male
Status Offline
Thanks for sharing!
Floor 26 Posted 2010-05-23 18:47 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Read the script, and you can continue to plot points and color by appending commands to script a.x for observation.

This is a prototype, identifying only three commands:
color red,green,blue
point x,y,z
sleep time


/* Directscript Reader, code by 523066680, 20100522 */

#include <stdio.h>
#include <GL/glut.h>
#include <stdlib.h>

#define xpix 500
#define ypix 500

int winid;
float deepa = -1.0, deepb = 1.0;

FILE *openx;

void display(void)
{
static int clear = 0;
if (clear == 0) {
glClear(GL_COLOR_BUFFER_BIT);
clear = 1;
}
glutSwapBuffers();
}

void reshape(int wx, int wy)
{
glViewport(0, 0, wx, wy);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, xpix, 0.0, ypix, 1.0, -1.0);
glMatrixMode(GL_MODELVIEW);
}

void hitkey(unsigned char key, int mousex, int mousey)
{
switch (key) {
case 'q':
glutDestroyWindow(winid);
exit(0);
break;
}
}

void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glPointSize(10);
if ((openx = fopen("./a.x", "r")) == NULL) {
printf("File not exist!");
exit(0);
}

}

int main(int argc, char *argv)
{
void readfile(void);
/*CreateGraphWindow*/
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(0, 0);
glutInitWindowSize(xpix, ypix);
winid = glutCreateWindow("dict");
init();
glutReshapeFunc(reshape);
glutKeyboardFunc(hitkey);
glutDisplayFunc(display);
glutIdleFunc(readfile);
glutMainLoop();

return 0;
}

void readfile(void)
{
int code;
enum command { color, sleep, point } cmd;
float a, b, c;
char str;
int apology(char *tmpstr);
fscanf(openx, "%s ", str);
if (!feof(openx)) {
code = apology(str);
switch (code) {
case color:
printf("read color : ");
fscanf(openx, "%f,%f,%f", &a, &b, &c);
printf("%f %f %f\n", a, b, c);
a = (int)a % 100 / 100.0;
b = (int)b % 100 / 100.0;
c = (int)c % 100 / 100.0;
glColor3f(a, b, c);
glutPostRedisplay();
break;
case sleep:
printf("sleep!\n");
fscanf(openx, "%f", &a);
_sleep((int)(600 * a));
break;
case point:
fscanf(openx, "%f,%f,%f", &a, &b, &c);
if (c < deepa || c > deepb) {
printf("ERR : z=%f, out of your window\n", c);
}
glBegin(GL_POINTS);
glVertex3f(a, b, c);
glEnd();
glutPostRedisplay();
printf("vertex3f: %f %f %f\n", a, b, c);
break;
default:
printf("No this command\n");
break;
}
} //else {usleep(600000.0);printf("end of text stream\n");}
}

int apology(char *tmpstr)
{
int i, fo = 3;
char str = { "color","sleep","point" };
for (i = 0; i < fo; i++) {
if (strcmp(str, tmpstr) == 0) {
break;
}
}
return i;
}



Compiled under Windows with Dev-CPP (including the glut library).

The following batch processing generates random commands to observe the effect

@echo off
set dict=project1.exe

type nul>a.x

set /a n=0
:a
set /a x=(%random% %%20) * 11, y=(%random% %%20) *11 , z=0
set /a a=%random% %%100, b=%random% %%100, c=%random% %%100
echo color %a%,%b%,%c% >>a.x
echo point %x%,%y%,%z% >>a.x
echo sleep 0.1 >>a.x
if %n% lss 80 (set /a n+=1 & goto a)
echo Press q in the graphics window to exit
start %dict%
pause
exit


I think this will be a pretty good start~

[ Last edited by 523066680 on 2010-5-23 at 18:50 ]
Floor 27 Posted 2010-06-09 19:38 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
```
@echo off
::::::::::::::::::::::::::::::::::::::::::::::::::
:: Temporary notebook, code by 523066680@cn-dos.net
::
:: Parameter: add Note content Add Note content to the note list
:: Parameter: del Number 1 Number 2 .... Delete the note with the specified number
:: Parameter is empty Directly read the note text
::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal enabledelayedexpansion
set notebook=notebook.x
set arg_del=del
set arg_add=add
set arg_=type

if not exist "%notebook%" (
echo %notebook% does not exist, will be created
type nul>>notebook.x
exit /b
)

if not defined arg_%1 (
echo Command %1 does not exist
exit /b
) else (
if "%1"=="" (goto :func_)
)

:read_it
::If the parameter is not empty, come here. Adding project numbers and deleting projects both need to read text information first
::text format: $number $date $note, range of number :
set /a note_n=0
for /f "tokens=1,2,*" %%a in ('type %notebook%') do (
set note_info_#%%a=%%b %%c
set /a note_n+=1
)
::Then jump to the function block
goto :func_%1


:func_
type %notebook%
exit /b

:func_del
set /a x=-1
if "%2"=="" (echo arg2 = NULL &exit /b)
if not defined note_info_#%2 (echo no this item. &exit /b)
::Assume that more than one item is deleted, the parameters are separated by spaces, and the total parameters are used as strings for judgment
for /f "tokens=1,*" %%a in ("%*") do (set note_items=%%b)
::Like 10, the deletion is 0. After simply replacing 0, it will also change. The subsequent judgment will delete, so it is dangerous. Add judgment factors
set note_items=#%note_items: =#%#
echo,>%notebook%
for /f "tokens=2,* delims==#" %%a in ('set note_info_#') do (
if "!note_items:#%%a#=!"=="!note_items!" (
set /a x+=1
set xnum= !x!
set xnum=!xnum:~-2!
echo !xnum! %%b>>%notebook%
) else (
echo Deleted item - %%a %%b
)
)
echo %notebook% rearranged, current situation :
type %notebook%
exit /b
:func_add
if "%2"=="" (echo Additional information is empty &exit /b)
set xnum= %note_n%
set xnum=!xnum:~-2!
set strnow=%*
::::cut string - "add "
set strnow=%strnow:~4%
(echo %xnum% %date:~0,10% %strnow%)>>%notebook%
echo %notebook% current situation :
type %notebook%
exit /b
```

Test:

c:\test>note add This is a test item
notebook.x current situation :

0 2010-06-08 Express delivery collection and delivery of goods not arrived
1 2010-06-08 Materials not counted
2 2010-06-09 Make a supplier address and phone information form
3 2010-06-09 This is a test item

c:\test>note del 1 2
Deleted item - 1 2010-06-08 Materials not counted
Deleted item - 2 2010-06-09 Make a supplier address and phone information form
notebook.x rearranged, current situation :

0 2010-06-08 Express delivery collection and delivery of goods not arrived
1 2010-06-09 This is a test item

c:\test>


[ Last edited by 523066680 on 2010-6-9 at 21:26 ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
zzz19760225 +2 2017-12-26 13:29
Floor 28 Posted 2010-07-13 17:36 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
I'm the kind who hasn't watched for dozens of episodes.
You know, it's really hard to watch online, flipping through one by one, so I decided to download all.
getpic.sh

#!/bin/bash
for ((fold=350;fold<=380;fold++))
do
if
then
mkdir $fold
fi
cd ./$fold
wget --no-clobber http://178.manmankan.com/BLEACH/$fold/{001..025}.jpg
cd ..
done
echo end
read -n1


Finished watching Bleach all at once, so then download Naruto.
Due to work, I often switch systems, sneaking around, so I also made a batch processing version:
Really envy that bash supports expansions like {1..4}=1 2 3 4..... When changing to batch processing, it becomes cumbersome.

@echo off
setlocal enabledelayedexpansion
set name=naruto
for /l %%x in (420,1,500) do (
if not exist %name%_%%x (md %name%_%%x)
cd %name%_%%x
for /l %%a in (1,1,25) do (
set num=000%%a
set num=!num:~-3!
wget -nc http://140.manmankan.com/naruto/%%x/!num!.jpg
)
cd ..
)


Finally, looking at it with an image viewer was really uncomfortable, so batch import into web pages.
Put the pictures of one episode on one page, so just flip once per episode.


@echo off
setlocal enabledelayedexpansion

for /l %%i in (420,1,500) do (
type nul>na_%%i.html
set /a left=%%i-1,right=%%i+1
echo ^<a href="na_!left!.html"^> 上一页 ^</a^> >>na_%%i.html
echo ^<a href="na_!right!.html"^> 下一页 ^</a^> ^<br^> >>na_%%i.html
for /l %%j in (1,1,25) do (
set num=000%%j
set num=!num:~-3!
(
echo ^<img src="naruto_%%i\!num!.jpg" /^>
echo ^<br^>
echo -----------------------------------------------------
echo ^</br^>
)>>na_%%i.html
)
echo ^<a href="na_!left!.html"^> 上一页 ^</a^> >>na_%%i.html
echo ^<br^> ^<a href="na_!right!.html"^> 下一页 ^</a^> >>na_%%i.html
echo %%i
)
pause
exit


[ Last edited by 523066680 on 2010-7-13 at 17:46 ]
Floor 29 Posted 2010-07-18 15:22 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
The execution order is: first MainGet.bat and then Act.bat. The other two are called.

MainGet.bat
First, obtain 1 - 10 pages with the list attached, where there are the sub - pages needed.

@echo off
set /a x=1
:main
wget -T 8 -t 1 主页_和谐/List/class_61_%x%.Html
if %x% lss 10 (set /a x+=1 &goto :main)


Act.bat
Responsible for extracting the list and sub - page addresses and handing them over to the download script.

@echo off
setlocal enabledelayedexpansion
set /a i=1
:main
echo class_61_%i%
for /f "tokens=*" %%a in ('type class_61_%i%.html ^|find /i "span class"') do (
set str=%%a
set str=!str:*/html/=!
for /f "tokens=1 delims=." %%x in ("!str!") do (
if not exist %%x (call downer.bat %%x)
)
)
if %i% lss 10 (set /a i+=1 &goto :main)


downer.bat is called by Act.bat
Analyze the image links in the sub - page and download all of them. Wait, a side issue, why when i % 3 = 1 and 2, external calls for downloading are made.
You know, code speed>download speed, external call, multi - process download will not take up time.
When the remainder is 0, the current process downloads, this is for buffering. If all are called externally, there is no buffering, it will become a bomb - like script.

@echo off
setlocal enabledelayedexpansion
set src=http://主页_被我和谐了/html/
set act=%1

:main
wget -T 5 -t 1 -nc %src%%act%.html
if %errorlevel% neq 0 (goto :eof)
if not exist %act% (mkdir %act%) else (goto :eof)
set /a i=0
cd %act%
for /f "tokens=2 delims= " %%a in ('type ..\%act%.html ^| find /i "img src"') do (
set /a i+=1,p=i %% 3
set str=%%a
set str=!str:*http=!
set str=!str:"=!
set name=000!i!
set name=!name:~-3!
echo !name!
if !p! equ 0 (
wget -T 8 -t 1 -O !name!.jpg http!str!
if !errorlevel! neq 0 (del !name!.jpg)
) else (
start /min ..\geter.bat %cd% !name!.jpg http!str!
)
)
cd ..


geter.bat
Called by downer.bat

@echo off
echo %1 %2 %3
cd %1
wget -T 8 -nc -t 1 -O %2 %3
if %errorlevel% neq 0 (del %2)
exit


[ Last edited by 523066680 on 2010 - 7 - 19 at 12:34 ]
Floor 30 Posted 2010-07-30 20:18 ·  中国 广东 深圳 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline

::::::::::::::::::::::::::::::::::::::::::::::::::
:: Code by 523066680@163.com
:: Start from drive F, find the disk that has the isme.x Then
:: Read the relevant directory names in isme.x and update the current directory to back up there
:: Because the drive letter of my mobile hard disk changes from time to time, so I wrote one to find the backup destination according to the marker file.
:: There may be multiple , so find /i "target information" to match the correct path
:: For example, the content of isme.x is Files\me, which means the end point is the files\me directory of the current disk
::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal enabledelayedexpansion
set source=%~dp0
::Find the disk where isme.x is located, read the target path if found
for %%a in (f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%a:\isme.x (
for /f "tokens=*" %%s in ('type %%a:\isme.x ^|find /i "me"') do (
set dest=%%s
set dest=%%a:\!dest!
)
)
)

if defined dest (goto :act) else (echo NOT FOUND &pause &exit)

:act
if "%source:~-1%"=="\" (set source=%source:~0,-1%)
if "%dest:~-1%"=="\" (set dest=%dest:~0,-1%)

if not exist "%dest%\" (
echo The directory %dest% for backup does not exist, and an attempt will be made to create it.
(md "%dest%")||(
echo An error occurred...
pause>nul
exit
)
goto :justcopy
)

echo Searching and cleaning up possible extra files or subfolders in "%dest%"
for /f "tokens=*" %%a in ('dir /a /s /b "%dest%"') do (
set pathname=%%a
set pathname=!pathname:%dest%\=!
if exist "%%a" (
if not exist %source%\!pathname! (
if exist "%%a\" (
tree %%a
rd /s /q "%%a"
) else (
del /f /a /q "%%a"
)
)
)
)

:justcopy
echo xcopying
if exist cut.txt (
xcopy /f /s /d /c /h /y /exclude:cut.txt "%source%" "%dest%"
) else (
xcopy /f /s /d /c /h /y "%source%" "%dest%"
)
echo Press any key to exit
pause>nul
exit


[ Last edited by 523066680 on 2010-7-30 at 20:23 ]
Forum Jump: