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-07-28 18:24
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Extract the characters (files) before the first TAB position in each line of the text and copy them View 2,091 Replies 29
Original Poster Posted 2007-06-20 16:51 ·  中国 广东 深圳 福田区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
myfile.txt 文本内容如下

.
.
C:\Program Files\InstallShield Installation Information\{EFB21DE7-8C19-4A88-BB28-A766E16493BC}\data1.cab 1,886KB A 2004-6-16 9:44:50

C:\Program Files\Common Files\InstallShield 1KB D 1601-1-1 8:00:00
C:\Program Files\Common Files\InstallShield\Professional 1KB D 1601-1-1 8:00:00
C:\Program Files\Common Files\InstallShield\Professional\RunTime 1KB D 1601-1-1 8:00:00
C:\Program Files\Common Files\InstallShield\Professional\RunTime\0701 1KB D 1601-1-1 8:00:00
C:\Program Files\Common Files\InstallShield\Professional\RunTime\0701\Intel32 1KB D 1601-1-1 8:00:00
C:\Program Files\Common Files\InstallShield\Professional\RunTime\0701\Intel32\ctor.dll 58KB A 2002-12-2 13:33:04

C:\Program Files\Common Files\InstallShield\Professional\RunTime\0701\Intel32\iuser.dll 156KB A 2002-12-5 14:10:32
C:\Program Files\Common Files\InstallShield\Professional\RunTime\0701\Intel32\setup.dll 283KB A 2007-6-20 19:17:16
C:\Program Files\Common Files\InstallShield\Professional\RunTime\iKernel.rgs 26KB A 2002-12-2 15:28:58
C:\Program Files\Common Files\InstallShield\Professional\RunTime\IsProBE.tlb 86KB A 2002-12-2 13:23:16
C:\Program Files\Common Files\InstallShield\Professional\RunTime\Objectps.dll 33KB A 2002-12-2 13:33:04
C:\Program Files\Common Files\Adobe\PDFL 1KB D 1601-1-1 8:00:00
C:\Program Files\Common Files\Adobe\PDFL\6.0 1KB D 1601-1-1 8:00:00
+++++++++++++++++++++++++++++++++++++++++++++++++++++
如下:
C:\Program Files\Common Files\Adobe\TypeSpt\
Unicode\Mappings\Adobe\JISX0208.txt ->D:\文件提取目录\Program Files\Common Files\Adobe\TypeSpt\
Unicode\Mappings\Adobe\JISX0208.txt

+++++++++++++++++++++++++++++++++++++++++++++++++++++

[ Last edited by beyoungse on 2007-6-20 at 09:27 PM ]
Floor 2 Posted 2007-06-20 16:52 ·  中国 广东 深圳 福田区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
For example:
MSCAL.DEP 1KB A 1998-4-24




copy MSCAL.DEP d:\test\
Floor 3 Posted 2007-06-20 16:57 ·  中国 河北 石家庄 北京神州长城通信技术发展中心中国长城互联网
初级用户
★★
Credits 152
Posts 75
Joined 2007-02-06 22:09
19-year member
UID 78805
Gender Male
Status Offline
对于 /f "tokens=1,*" %%a in (yourfile.txt) do copy 路径\%%a d:\test\
Floor 4 Posted 2007-06-20 17:18 ·  中国 广东 深圳 福田区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
Thank you, it's okay. Studying hard.
Floor 5 Posted 2007-06-20 19:39 ·  中国 广东 深圳 福田区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
C:\Program Files\Common Files\InstallShield\Professional\RunTime\iKernel.rgs 26KB A 2002-12-2 15:28:58
C:\Program Files\Common Files\InstallShield\Professional\RunTime\IsProBE.tlb 86KB A 2002-12-2 13:23:16
C:\Program Files\Common Files\InstallShield\Professional\RunTime\Objectps.dll 33KB A 2002-12-2 13:33:04
C:\Program Files\Common Files\Adobe\PDFL 1KB D 1601-1-1 8:00:00
C:\Program Files\Common Files\Adobe\PDFL\6.0 1KB D 1601-1-1 8:00:00
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps 1KB D 1601-1-1 8:00:00
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\90ms-RKSJ-UCS2 113KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\90pv-RKSJ-UCS2 2KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\90pv-RKSJ-UCS2C 103KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-CNS1-B5pc 8KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-CNS1-ETen-B5 9KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-CNS1-H-CID 2KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-CNS1-H-Host 9KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-CNS1-H-Mac 8KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-CNS1-UCS2 262KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-GB1-GBK-EUC 94KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-GB1-GBpc-EUC 5KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-GB1-H-CID 2KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-GB1-H-Host 95KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-GB1-H-Mac 5KB 2003-4-22 14:57:18
C:\Program Files\Common Files\Adobe\PDFL\6.0\CMaps\Adobe-GB1-UCS2 234KB 2003-4-22 14:57:18

Copy the files of the same level in the C drive to the D drive directory and copy them together
C:\Program Files\Common Files\InstallShield\Professional\RunTime\iKernel.rgs
->D:\Program Files\Common Files\InstallShield\Professional\RunTime\iKernel.rgs
Floor 6 Posted 2007-06-20 19:57 ·  中国 广东 深圳 福田区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
“C:\Program Files\Common Files\*.*"
There are two spaces in the middle, I don't know how to fix it, please help, expert!
Floor 7 Posted 2007-06-20 20:00 ·  中国 广东 深圳 福田区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
How to represent the file/folder before the first TAB position
Floor 8 Posted 2007-06-20 20:10 ·  中国 上海 电信
中级用户
★★
Credits 231
Posts 112
Joined 2007-06-19 20:44
19-year member
UID 91827
Gender Male
Status Offline
The spaces in each paragraph here are all the same length. Why not replace all the spaces in the file with <tab> symbols and then copy it into Excel so that it can be separated?

Or use the space segment as a delimiter to import into the database.

Why go to the trouble of using batch processing?
Floor 9 Posted 2007-06-20 20:19 ·  中国 广东 深圳 福田区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
My purpose is to perform a copy. Save the files with the same hierarchy in the C drive to the D drive, and copy the directory as well.
C:\Program Files\Common Files\InstallShield\Professional\RunTime\iKernel.rgs
->D:\Program Files\Common Files\InstallShield\Professional\RunTime\iKernel.rgs
Floor 10 Posted 2007-06-20 20:28 ·  中国 上海 电信
中级用户
★★
Credits 231
Posts 112
Joined 2007-06-19 20:44
19-year member
UID 91827
Gender Male
Status Offline
After exporting the target file, insert all with xcopy /e.

UltraEdit supports single-column insertion, insert xcopy in front of each column, and insert the drive letter at the back.

Or in Excel or database, add an empty column in front, put xcopy, and write the drive letter in the empty column at the back.

Finally, copy it to the bat for execution.
Floor 11 Posted 2007-06-20 20:31 ·  中国 上海 电信
中级用户
★★
Credits 231
Posts 112
Joined 2007-06-19 20:44
19-year member
UID 91827
Gender Male
Status Offline
If you must use for, you can use delims=

Reset the replacement delimiter to that space segment~

Postscript

This method is wrong. The for in DOS does not support string as the delimiter yet.

[ Last edited by duanml on 2007-6-20 at 08:48 PM ]
Floor 12 Posted 2007-06-20 20:33 ·  中国 广东 深圳 福田区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
for /f "delims=1,*" %%a in (file.txt) do xcopy /I /e/s %%a D:\

The error messages are as follows, and also "~~~~~~~~~~~ 809KB 2002-8-6 " will appear

D:\>xcopy /I /e/s C:\Program Files\Common Files\Adobe
TypeSpt\Unicode\Mappings\Win\CP949.TXT 809KB 2002-8-6 D:\
Invalid number of parameters

D:\>xcopy /I /e/s C:\Program Files\Common Files\Adobe
TypeSpt\Unicode\Mappings\Win\CP950.TXT 523KB 2002-8-6 D:\Invalid number of parameters

D:\>xcopy /I /e/s C:\WINDOWS\system32\spool\drivers\c
lor\JapanColor200 D:\File not found - JapanColor200
0 files copied

[ Last edited by beyoungse on 2007-6-20 at 08:40 PM ]
Floor 13 Posted 2007-06-20 20:39 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
```gawk -v sign=" -F" " "BEGIN{OFS=""}/^C/{print "copy ",sign,$1,sign," ",sign,"D"substr($1,2),sign}" yourfile.ext"|more>run.bat
call run.bat

#Gawk Download
Post 9
http://www.cn-dos.net/forum/viewthread.php?tid=31098```
Floor 14 Posted 2007-06-20 20:46 ·  中国 上海 电信
中级用户
★★
Credits 231
Posts 112
Joined 2007-06-19 20:44
19-year member
UID 91827
Gender Male
Status Offline
I made a mistake. Now the for in DOS doesn't support using strings as delimiters.

You can use the administrator's software, or the method I mentioned of separating with UltraEdit, Excel, etc., and then inserting columns.
Floor 15 Posted 2007-06-20 20:49 ·  中国 广东 深圳 福田区 电信
中级用户
★★
Credits 253
Posts 112
Joined 2005-12-20 00:31
20-year member
UID 47500
Status Offline
It doesn't work with the class master of lxmxn either. Let's modify it again.

D:\>copy "C:\Program Files\Common Files\Adobe\TypeSpt\
Unicode\Mappings\Adobe\JISX0208.txt 107KB 2002-10-15 10:24:42
" "D:\Program Files\Common Files\Adobe\TypeSpt\Unicode\Mappings\Adobe\JISX
0208.txt 107KB 2002-10-15 10:24:42
"
The system cannot find the specified file.

Strengthen it a bit more. The target folder is in D:\File Extraction Directory\
C:\Program Files\Common Files\Adobe\TypeSpt\
Unicode\Mappings\Adobe\JISX0208.txt ->D:\File Extraction Directory\Program Files\Common Files\Adobe\TypeSpt\
Unicode\Mappings\Adobe\JISX0208.txt

[ Last edited by beyoungse on 2007-6-20 at 08:50 PM ]
Forum Jump: