复制所有文件内容到新文件 - 批 [英] Copying all file contents into new files - Batch
问题描述
我需要做的是(我有一些想法,就不能得到这种凝固):
- 阅读一个目录(循环)的所有文件
- 在循环中,我需要在循环的内容,当前文件拷贝到同一个目录中的新文件(x.txt到x2.txt)。这可以用一个类型>>命令完成。
我更困惑了它的循环的一部分。我该怎么做呢?
编辑:
这是我当前的脚本:
FOR %% I IN(*)
难道型%% I>> %% I2
这将复制每个 .TXT
文件与扩展名的备份文件。 TXT2
:
为%i的(* .txt)中做键入%i的> %I2
请注意,在一个批处理文件,你需要加倍%
:
为%% i的(* .txt)中做键入%%我> %% I2
如果你想倒入同一个结果文本文件中的所有找到的文件这不是从你的问题清楚,或者如果你希望每个之一,对单拷贝。
如果你只是想要一个结果文件,你也可以使用复制命令,即的变体:
复制* .TXT output.dat
What I need to do is (and I have some idea, just can't get this solidified):
- Read all files in a directory (for loop)
- In loop, I need to copy the current file in the loop's contents into a new file (x.txt into x2.txt) in the same directory. This can be done with a type >> command.
I'm more confused about the looping part of it. How do I do that?
Edit:
This is my current script:
FOR %%i IN (*)
Do type %%i >> %%i2
This will copy each .txt
file to a backup file with extension .txt2
:
for %i in (*.txt) do type "%i" > "%i2"
Note that in a batch file you need to double the %
:
for %%i in (*.txt) do type "%%i" > "%%i2"
It's not clear from your question if you want all found files dumped into the same resulting text file or if you want one-to-one copies of each.
If you just want one results file, you could also use a variant of the copy command, i.e.:
copy *.txt output.dat
这篇关于复制所有文件内容到新文件 - 批的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!