Board logo

标题: 请指点如何自动顺序依次打开文件?? [打印本页]

作者: biobio     时间: 2007-3-15 12:57    标题: 请指点如何自动顺序依次打开文件??

例如:
A文件夹下有10个.txt文本文档,名字分别是01.txt 02.txt 03.txt依此类推,最后是10.txt

我现在想按名字顺序一次打开文档,并内容显示在cmd,我写了如下批处理

more 01.txt
more /c 02.txt
more /c 03.txt
more /c 04.txt
more /c 05.txt
more /c 06.txt
more /c 07.txt
more /c 08.txt
more /c 09.txt
more /c 10.txt
pause

我总觉得太复杂麻烦了,有没有简单点的写法?

有没有办法实现后退和前进效果

比如:已经显示到06.txt文本内容了,我又想看看04.txt文本的内容

或者是想快速看到10.txt内容?如何实现?
作者: lxmxn     时间: 2007-3-15 13:35
http://www.cn-dos.net/forum/view ... ;highlight=%2Blxmxn

  看看这个帖子中的第6个——“View_Context.bat”,修改一下就可以用啦。

作者: biobio     时间: 2007-3-15 23:19    标题: 要打开指定文件夹中的文本,怎样修改?

::Code by lxmxn @ cn-dos.net
::列出当前文件夹中所有文本文件,并用记事本根据文件编号选择打开哪个
::Modified 23:03 2007-1-12

@echo off&setlocal EnableDelayedExpansion
    set/a n=0
    for /f "delims=" %%i in ('dir /b/a-d *.txt *.bat *.vbs *.js *.html *.ini *.inf') do (
        set/a n+=1
        echo ^(!n!^)_%%i
        set file!n!=%%i
    )
rem 打开文件
   
    set /p choose=请选择要打开的文件:
    if not defined choose (cls&echo;&set/p=     输入错误&exit/b 0)
    if %choose% gtr %n% (cls&echo;&set/p=     输入错误&exit/b 0)
    notepad.exe "!file%choose%!"
    )
    pause
作者: lxmxn     时间: 2007-3-15 23:26

  在代码的开头进入你要打开的目录,比如:cd /d D:\mydir\movie。

作者: biobio     时间: 2007-3-16 02:29
谢谢你的帮助
作者: biobio     时间: 2007-3-16 02:49    标题: 还想问一下,怎样按文件名顺序排列?

还想问一下,怎样按文件名顺序排列?
比如 01.txt 02.txt 03.txt 04.txt

在CMD显示出来时,是这样

(1)02.txt
(2)01.txt
(3)04.txt
(4)03.txt
请选择要打开的文件:

能否按文件名顺序排列?
作者: biobio     时间: 2007-3-16 08:01
向 老大 lxmxn 致敬!!!!!!!!!!!!!