. : : ClassiClub ForuM : : .

会员中心 论坛帮助 日历事件 标记论坛已读
返回   精品技术论坛 » 技术论坛 » 『软件使用』

『软件使用』: 电脑软件推荐, 电脑软件使用, 经验分享



发表新主题 关闭主题
 
主题工具
江楼月
 
江楼月 的头像
超级会员
 
资 料:
注册日期: Aug 2002
帖子: 1,454 声望值: 3
精华: 0
#1 旧 2007-09-21, 14:59:41 默认 【求助】DOS里怎么样把C盘下的所有DOC文件都复制到D盘
江楼月 当前离线  

文件在不同的文件夹下。
dlr2088
 
dlr2088 的头像
支柱会员
 
资 料:
注册日期: Dec 2001
帖子: 5,109 声望值: 0
精华: 0,解答: 3
#2 旧 2007-09-21, 15:08:20 默认
dlr2088 当前离线  

NTFS分区吗?还是FAT32/Fat!~??

如果是前者利用现在很多成熟的DOS工具(比如MaxDOS),进入DOS平台使用xcopy很好解决。
HappyDragon
 
HappyDragon 的头像
核心会员
 
资 料:
注册日期: Jul 2003
帖子: 3,691 声望值: 3
精华: 0,解答: 3
#3 旧 2007-09-21, 16:47:44 默认
HappyDragon 当前离线  

copy c:\xxxx\*.doc d:不行吗?


君子博学而日参省乎己,则知明而行无过矣。
大老鼠
 
大老鼠 的头像
高级会员
 
资 料:
注册日期: Mar 2001
帖子: 925 声望值: 3
精华: 0
#4 旧 2007-09-21, 16:57:54 默认
大老鼠 当前离线  

xcopy c:\ *.doc d: /s


一切有情身中 具有此觉悟莲花 清净世界不染烦恼
[CCF]BigMouse
小轩
 
小轩 的头像
核心会员
 
资 料:
注册日期: Dec 2005
帖子: 3,025 声望值: 3
精华: 0,解答: 5
#5 旧 2007-09-21, 17:26:39 默认
小轩 当前离线  

加/s/e(/e可以在D盘建立相同文件夹)


My Maxim
≡ All for one, One for all. ≡
江楼月
 
江楼月 的头像
超级会员
 
资 料:
注册日期: Aug 2002
帖子: 1,454 声望值: 3
精华: 0
#6 旧 2007-09-22, 17:43:55 默认
江楼月 当前离线  

引用:
作者: dlr2088 查看帖子
NTFS分区吗?还是FAT32/Fat!~??

如果是前者利用现在很多成熟的DOS工具(比如MaxDOS),进入DOS平台使用xcopy很好解决。
非常感谢推荐的MaxDOS。
iou
 
iou 的头像
超级会员
 
资 料:
注册日期: Feb 2002
帖子: 1,346 声望值: 2
精华: 0
#7 旧 2007-11-21, 15:34:32 默认
iou 当前离线  

cmd下copy 不行吗 ?


宝剑,磨砺出锋.梅花,寒中绽放,不经一番寒彻骨,怎得梅花扑鼻香
jr21066
 
jr21066 的头像
热心会员
 
资 料:
注册日期: Mar 2002
帖子: 14,648 声望值: 6
精华: 15,解答: 52
#8 旧 2007-11-21, 16:12:04 默认
jr21066 当前离线  

引用:
作者: iou 查看帖子
cmd下copy 不行吗 ?
楼主说了。

引用:
作者: 江楼月 查看帖子
文件在不同的文件夹下。


所有的人都站在一边并不一定是好事,譬如他们都站在船的一边
aaabbb
 
aaabbb 的头像
高级会员
 
资 料:
注册日期: Dec 2000
帖子: 657 声望值: 3
精华: 0
#9 旧 2007-11-21, 16:58:40 默认
aaabbb 当前离线  

for /f "tokens=*" %i in ('dir/s/b C:\*.doc') do copy "%i" d:\
river01
 
river01 的头像
核心会员
 
资 料:
注册日期: Dec 2002
帖子: 2,604 声望值: 3
精华: 0,解答: 6
#10 旧 2007-11-21, 17:03:25 默认
river01 当前离线  

引用:
作者: aaabbb 查看帖子
for /f "tokens=*" %i in ('dir/s/b C:\*.doc') do copy "%i" d:\
这个厉害了,tokens什么意思
aaabbb
 
aaabbb 的头像
高级会员
 
资 料:
注册日期: Dec 2000
帖子: 657 声望值: 3
精华: 0
#11 旧 2007-11-21, 17:27:26 默认
aaabbb 当前离线  

tokens=x,y,m-n - specifies which tokens from each line are to
be passed to the for body for each iteration.

如果不用的话,有空格的文件名只有第一空格前的部分。
recyclebin
 
recyclebin 的头像
超级会员
 
资 料:
注册日期: Sep 2000
帖子: 1,668 声望值: 2
精华: 0,解答: 1
#12 旧 2007-11-21, 18:04:58 默认
recyclebin 当前离线  

引用:
作者: aaabbb 查看帖子
tokens=x,y,m-n - specifies which tokens from each line are to
be passed to the for body for each iteration.

如果不用的话,有空格的文件名只有第一空格前的部分。
谁能解释一下,我只会用XCOPY


====
===
==
=
mllm
 
mllm 的头像
高级会员
 
资 料:
注册日期: Jan 2001
帖子: 770 声望值: 2
精华: 0
#13 旧 2007-11-21, 21:23:03 默认
mllm 当前离线  

引用:
作者: river01 查看帖子
这个厉害了,tokens什么意思
应该是For循环语句中的一个可选字段
引用:
FOR /F

Loop command: against a set of files - conditionally perform a command against each item.

Syntax
FOR /F ["options"] %%parameter IN (filenameset) DO command

FOR /F ["options"] %%parameter IN ("Text string to process") DO command

Key
options:
delims=xxx The delimiter character(s) (default = a space)

skip=n A number of lines to skip at the beginning of the file.
(default = 0)

eol=; Character to indicate a comment (end of line)

tokens=n Specifies which numbered items to read from each line
(default = 1)

usebackq Specify `back quotes`:
- Use double quotes to quote long file names in filenameset.
- Use single quotes for 'Text string to process'
(useful if the text string contains double quotes)

Filenameset : A set of one or more files. Wildcards may be used.
If (filenameset) is a period character (.) then FOR will
loop through every file in the folder.
command : The command to carry out, including any
command-line parameters.

%%parameter : A replaceable parameter:
in a batch file use %%G (on the command line %G)FOR /F processing of each text file consists of reading the file one line of text at a time and then breaking the ine up into individual items of data or 'tokens'. The DO command is then executed with the parameter(s) set to the token(s) found.

By default, /F breaks up the line at each blank space, and any blank lines are skipped.
You can override this default parsing behavior by specifying the "options" parameter. The options must be contained within "quotes"

Within a FOR loop the visibility of FOR variables is controlled via SETLOCAL EnableDelayedExpansion

The ` backquote character is just below the ESC key on most keyboards, the usebackq option is not available in NT4 or earlier.

Tokens
tokens=2,4,6 will cause the second, fourth and sixth items on each line to be processed

tokens=2-6 will cause the second, third, fourth, fifth and sixth items on each line to be processed

tokens=* will cause all items on each line to be processed

tokens=3* will cause the 3rd and all subsequent items on each line to be processed

Specifying more than 1 token will cause additional parameter names to be allocated.

If the last character in the tokens= string is an asterisk, then additional parameters are allocated for all the remaining text on the line.

Delims
Specifying more than one delimiter has been known to cause problems with some data sets, if you have problems try parsing with just one delimiter at a time. When more than one delimiter is specified it's an OR, i.e either delimiter will work. If you don't specify anything it will default to "delims=<tab><space>"

When editing a CMD script notice that many text editors will fail to enter the TAB character correctly.

You can use any character as a delimiter - but they are case sensitive.

Examples

Parse the output of a command:

FOR /F %%G IN ('"C:\program Files\command.exe"') DO ECHO %%G

Parse the contents of a file:

FOR /F "usebackq tokens=1,2* delims=," %%G IN ("C:\My Documents\my textfile.txt") DO ECHO %%G

FOR /F "tokens=1,2* delims=," %%G IN (C:\MyDocu~1\mytex~1.txt) DO ECHO %%G

Using tokens to Parse a text file:

myfile.txt
[
12-AUG-99,DEPOSIT,450,23,55
; start of the new year
14-JAN-00,WITHDRAWAL,285,122
03-FEB-00,DEPOSIT,200
]

FOR /F "tokens=1,3* delims=," %%G IN (myfile.txt) DO @echo %%G %%H %%I

This will split each line into tokens delimited by a comma, ignoring lines that begin with a semicolon, as shown below.

"12-AUG-99" DEPOSIT "450" "23,55"
token1 token3 * = All the rest
%%G %%H %%I

%%G is explicitly declared in the FOR statement and the %%H and %%I are implicitly declared via the tokens= option. You can specify up to 26 tokens via the tokens= line, provided this does not cause an attempt to declare a parameter higher than the letter 'Z'.

FOR parameter names are global, so in complex scripts which call one FOR statement from within another FOR statement you can refer to both sets of parameters. You cannot have more than 26 parameters active at any one time.

Parse a text string:
A string of text will be treated just like a single line of input from a file, the string must be enclosed in double quotes (or single quotes with usebackq).

Echo the dollar amount and the date
FOR /F "tokens=1,3* delims=," %%G IN ("12-AUG-99,deposit,$45.50,23.7") DO @echo %%H was paid on %%G

Filenameset

To specify an exact set of files to be processed, such as all .MP3 files in a folder including subfolders and sorted by date - just use the DIR /b command to create the list of filenames ~ and use this variant of the FOR command syntax.

Unicode

Many of the newer commands and utilities (e.g. WMIC) output text files in unicode format, these cannot be read by the FOR command which expects ASCII.
To convert the file format use the TYPE command.

"It's completely intuitive; it just takes a few days to learn, but then it's completely intuitive" - Terry Pratchett.

Related Commands:

FOR - Loop commands
FOR - Loop through a set of files in one folder
FOR /R - Loop through files (recurse subfolders)
FOR /D - Loop through several folders
FOR /L - Loop through a range of numbers
FOR /F - Loop through the output of a command
FORFILES - Batch process multiple files
IF - Conditionally perform a command
SETLOCAL - Control the visibility of environment variables inside a loop

Equivalent Linux BASH commands:

cut - Divide a file into several columns
case - Conditionally perform a command
eval - Evaluate several commands/arguments
for - Expand words, and execute commands
until - Execute commands (until error)
while - Execute commands




Dell LATITUDE D600
FinePix S602Zoom
O2 ATOM EXEC
river01
 
river01 的头像
核心会员
 
资 料:
注册日期: Dec 2002
帖子: 2,604 声望值: 3
精华: 0,解答: 6
#14 旧 2007-11-22, 08:33:57 默认
river01 当前离线  


这个FOR语句用处很大啊。
icemanf
 
icemanf 的头像
热心会员
 
资 料:
注册日期: Dec 2001
帖子: 9,889 声望值: 6
精华: 1,解答: 1
#15 旧 2007-11-22, 08:49:11 默认
icemanf 当前离线  

最后面跟个/S


“你丫竟然上精品不回帖!”
[以德为本, 勤俭持家]-[爱我MM一生一世][快乐成双, 忧愁减半]-[不管别人事]
[紫砂壶专题]-[我们的茶文化]--[丽江行]
发表新主题 关闭主题

主题工具

论坛规则  发帖规则
不可以发表主题
不可以回复帖子
不可以上传附件
不可以编辑自己的帖子
论坛启用 vB 代码
版面启用 表情符号
版面启用 [IMG] 代码
版面禁用 HTML 代码


所有时间均为北京时间, 现在的时间是 20:46:40.

本论坛带宽由迅通网络提供
SSL证书由TrustAsia提供

Copyright © 2000 - 2019 ClassiClub Forum All Rights Reserved.
粤ICP备09123456号