如何在可变文件夹上移动文件

时间:2015-10-27 06:34:55

标签: batch-file cmd

有人从这里给我这个代码,根据用户想要的数量

创建多个文件夹

我在想,如果我仍然能够添加一个算法,它会将文件平均移动到创建的文件夹中,我将如何操作?

@echo off
set "FolderCount=1"

set /P "FolderCount=Enter number of folders (default: %FolderCount%): "

for /L %%N in (1,1,%FolderCount%) do md "Folder%%N" 

我非常需要它。任何建议,建议和意见将不胜感激。

这就是我做的事情

@echo off
set "FolderCount=1"
set /P "FolderCount=Enter number of folders (default: %FolderCount%): "
for /L %%N in (1,1,%FolderCount%)  
do md "Folder%%N"
for %%f (*.txt)

move /y "%%f" "Folder%%N"

set "FolderCount="

1 个答案:

答案 0 :(得分:0)

文件平均复制到创建的文件夹:

@echo off
set "FolderCount=1"
set /P "FolderCount=Enter number of folders (default: %FolderCount%): "
rem next command to treat possible answer `two` etc.
set /A "FolderCount=FolderCount"
for /L %%N in (1,1,%FolderCount%) do (
  md "Folder%%N" 2>NUL
  copy /y *.txt "Folder%%N\"
)

文件移动到创建的所有文件夹:

@echo off
set "FolderCount=1"
set /P "FolderCount=Enter number of folders (default: %FolderCount%): "
set /A "FolderCount=FolderCount"
for /L %%N in (1,1,%FolderCount%) do (
  md "Folder%%N" 2>NUL
  if %%N EQU 1 (
     move /y "*.txt" "Folder%%N\"
  ) else (
     copy /y "Folder1\*.txt" "Folder%%N\"
  )
)

copy / move个文件静默使用copy /y *.txt "Folder%%N\" >NUL 2>&1

资源(必读):