Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Im a bit of a noob on programming so i need some help. Im using windows 7 BTW

i have several folders ; 0,A,B,C,D etc. each contains somewhere between 150 and 8000 files that start with the same letter as the folder they are in( so they are sorted). the problem is, that the piece of software i need to use these files on only displays up to 254 files per folder. So what i need, is a way to sort these files in the folders into subfolders with max 254 files in each. So the result will be something like this:

A:\ A1(256 files) A2(256 files) A3(256 files) A4(120 files)

share|improve this question

migrated from stackoverflow.com Nov 11 '13 at 18:23

This question came from our site for professional and enthusiast programmers.

1 Answer 1

With c# use something like this should get you started:

  string[] saFilelist = Directory.GetFiles(@"A:\A");
  int iNumOfFoldersToCreate = saFilelist.Length/256;
    for(int i = 0; i<iNumOfFoldersToCreate ; i++)
    {
        string sCurrentDir = @"A:\A" + i.ToString();
        Directory.CreateDirectory(sCurrentDir );
        for(int j = 0; j<256 ; j++)
        {

            File.Move(saFilelist[i*256+j], sCurrentDir + "\\" + Path.GetFileName(saFilelist[i*256+j])); 

        }
    }
share|improve this answer
    
is it possible to do in other ways? i dont own c# and have no idea how to use it? :-) –  user2969051 Nov 8 '13 at 15:54
    
You can download a free version of c# from here: microsoft.com/en-gb/download/details.aspx?id=40787 –  Damo May 30 at 10:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.