如何将特定文件从文件夹移动到txt文件指定的另一个文件夹?

时间:2014-07-13 23:52:51

标签: batch-file

我有很多xml文件,我想将它们移动到某些文件夹。我想指定要在txt文件中移动的文件列表。

让我解释一下......

这是一本超过5000字的迷你词典,我想将它们分成20个单位。因为我想移动而不是复制xml文件以查看剩下的单词并决定它们在哪个单元中。

2 个答案:

答案 0 :(得分:0)

要复制文件,您必须将此代码放入批处理文件

@echo off
mkdir "C:\newfolder\unit1
mkdir "C:\newfolder\unit2
mkdir "C:\newfolder\unit3
mkdir "C:\newfolder\unit4
mkdir "C:\newfolder\unit5
mkdir "C:\newfolder\unit6
mkdir "C:\newfolder\unit7
mkdir "C:\newfolder\unit8
mkdir "C:\newfolder\unit9
mkdir "C:\newfolder\unit10
mkdir "C:\newfolder\unit11
mkdir "C:\newfolder\unit12
mkdir "C:\newfolder\unit13
mkdir "C:\newfolder\unit14
mkdir "C:\newfolder\unit15
mkdir "C:\newfolder\unit16
mkdir "C:\newfolder\unit17
mkdir "C:\newfolder\unit18
mkdir "C:\newfolder\unit19
mkdir "C:\newfolder\unit20
mkdir "C:\newfolder\unit21
mkdir "C:\newfolder\unit22
mkdir "C:\newfolder\unit23
mkdir "C:\newfolder\unit24
mkdir "C:\newfolder\unit25
mkdir "C:\newfolder\unit26
echo each unit has diffrent words. EX: Unit 1 has a's, Unit 2 has b's, etc.
pause >nul
cls
set /p u1=do you want to move unit 1?y/n?
if %u1%==y(
move /-y "C:\folder\a*.xml "C:\newfolder\unit1"
)
set /p u2=do you want to move unit 2?y/n?
if %u2%==y(
move /-y "C:\folder\b*.xml "C:\newfolder\unit2"
)
set /p u3=do you want to move unit 3?y/n?
if %u3%==y(
move /-y "C:\folder\c*.xml "C:\newfolder\unit3"
)
set /p u4=do you want to move unit 4?y/n?
if %u4%==y(
move /-y "C:\folder\d*.xml "C:\newfolder\unit4"
)
set /p u5=do you want to move unit 5?y/n?
if %u5%==y(
move /-y "C:\folder\e*.xml "C:\newfolder\unit5"
)
set /p u6=do you want to move unit 6?y/n?
if %u6%==y(
move /-y "C:\folder\f*.xml "C:\newfolder\unit6"
)
set /p u7=do you want to move unit 7?y/n?
if %u7%==y(
move /-y "C:\folder\g*.xml "C:\newfolder\unit7"
)
set /p u8=do you want to move unit 8?y/n?
if %u8%==y(
move /-y "C:\folder\h*.xml "C:\newfolder\unit8"
)
set /p u9=do you want to move unit 9?y/n?
if %u9%==y(
move /-y "C:\folder\i*.xml "C:\newfolder\unit9"
)
set /p u10=do you want to move unit 10?y/n?
if %u10%==y(
move /-y "C:\folder\j*.xml "C:\newfolder\unit10"
)
set /p u11=do you want to move unit 11?y/n?
if %u11%==y(
move /-y "C:\folder\k*.xml "C:\newfolder\unit11"
)
set /p u12=do you want to move unit 12?y/n?
if %u12%==y(
move /-y "C:\folder\l*.xml "C:\newfolder\unit12"
)
set /p u13=do you want to move unit 13?y/n?
if %u13%==y(
move /-y "C:\folder\m*.xml "C:\newfolder\unit13"
)
set /p u14=do you want to move unit 14?y/n?
if %u14%==y(
move /-y "C:\folder\n*.xml "C:\newfolder\unit14"
)
set /p u15=do you want to move unit 15?y/n?
if %u15%==y(
move /-y "C:\folder\o*.xml "C:\newfolder\unit15"
)
set /p u16=do you want to move unit 16?y/n?
if %u16%==y(
move /-y "C:\folder\p*.xml "C:\newfolder\unit16"
)
set /p u17=do you want to move unit 17?y/n?
if %u17%==y(
move /-y "C:\folder\q*.xml "C:\newfolder\unit17"
)
set /p u18=do you want to move unit 18?y/n?
if %u18%==y(
move /-y "C:\folder\r*.xml "C:\newfolder\unit18"
)
set /p u19=do you want to move unit 19?y/n?
if %u19%==y(
move /-y "C:\folder\s*.xml "C:\newfolder\unit19"
)
set /p u20=do you want to move unit 20?y/n?
if %u20%==y(
move /-y "C:\folder\t*.xml "C:\newfolder\unit20"
)
set /p u21=do you want to move unit 21?y/n?
if %u21%==y(
move /-y "C:\folder\u*.xml "C:\newfolder\unit21"
)
set /p u22=do you want to move unit 22?y/n?
if %u22%==y(
move /-y "C:\folder\v*.xml "C:\newfolder\unit22"
)
set /p u23=do you want to move unit 23?y/n?
if %u23%==y(
move /-y "C:\folder\w*.xml "C:\newfolder\unit23"
)
set /p u24=do you want to move unit 24?y/n?
if %u24%==y(
move /-y "C:\folder\x*.xml "C:\newfolder\unit24"
)
set /p u25=do you want to move unit 25?y/n?
if %u25%==y(
move /-y "C:\folder\y*.xml "C:\newfolder\unit25"
)
set /p u26=do you want to move unit 26?y/n?
if %u26%==y(
move /-y "C:\folder\z*.xml "C:\newfolder\unit26"
)
echo DONE!
pause >nul

这个新方法会将每个字母移动到自己的单位。

编辑:现在用户已经定义了!

我希望这适合你!

答案 1 :(得分:0)

这将移动file.txt中列出的文件并将其移至第2行所示的文件夹。

@echo off
set "target=d:\folder"
md "%target%" 2>nul
for /f "usebackq delims=" %%a in ("file.txt") do move "%%a" "%target%"