我想帮助您创建一个脚本,我可以使用该脚本从我拥有的文件夹中移动文件。多个文件,并将它们总共移动到一组目录10。然后循环,第11个文件将被复制到第一个目录,如下例所示:
1.txt folder 1
2.txt folder 2
3.txt folder 3
4.txt folder 4
5.txt folder 5
6.txt folder 6
7.txt folder 7
8.txt folder 8
9.txt folder 9
10.txt folder 10
11.txt folder 1
12.txt folder 2
13.txt folder 3
14.txt folder 4
我需要1.txt移动到文件夹1然后2.txt移动到文件夹2然后通过10.txt到文件夹10然后将11.txt移动到文件夹1然后12.txt移动到文件夹2然后移动到13。 txt移动到文件夹3。
答案 0 :(得分:0)
实际实现将取决于您编写脚本的平台(这是一个javaish片段),但一般逻辑将是这样的。
String[] fileNames = getFileNames(); //some method to retrieve all files your interested in or just pass in as argument`
String[] folderNames = {"folder1","folder2","folder3","folder4","folder5", "folder6","folder7","folder8","folder9","folder10"};
int i = 0;
for (String fileName : fileNames)
if (i == 9)
copyFile to folderNames[i]
i = 0
else
copyFile to folderNames[i]
i++;
这至少应该让你开始,显然没有复制文件,但这不是你问的问题。这只是循环数组以产生所需效果的简单逻辑。