Folder and File copy
I would like to have you help create a script that i can use to move files from folders that i have. multiple files and have them moved to a set of directories 10 in total. which then loops around that the 11th file woul开发者_如何学运维d be copied to the first directory like the example below:
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
I would need the 1.txt move to folder 1 then 2.txt to folder 2 and so thru 10.txt to folder 10 then have 11.txt move to folder 1 then 12.txt move to folder 2 then 13.txt move to folder 3.
The actual implementation will depend on the platform you write the script on (here is a javaish snippet), but general logic would be something like this.
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++;
This should at least get you started, obviously left out the copying of files but thats not what you asked about. This is just simple logic to loop around a array to produce your effect desired.
精彩评论