473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Sorting files by size

Hello,

I want to make a program that moves files from a main directory to a
sub directory.
Suggeset that i have 2000 files, the program will create 4 sub
directory's and move 500 files to each directory.

I think until this point it wont be a problem, but.... I want the
files to be ordered by filesize.
I mean that the first 500 files that will be moved will have the
smallest filesize and so on.

I dan't know if it is possible and ofcourse how to do it...

Is there anyone who can provide me a solution or a push in the good
direction???

Thanks in advance
Nov 21 '05 #1
4 1313
Niels,

I do not see the sense, however that is not important, using the
directoryinfo class and the file move, this should be a piece of cake.

http://msdn.microsoft.com/library/de...classtopic.asp

I took first the wrong link, maybe you need that as well, you see the file
move in that.
http://msdn.microsoft.com/library/de...classtopic.asp

I assume that you know how to sort an array

I hope this helps?

Cor
Nov 21 '05 #2
"Niels" <ni****@hollandridderkerk.nl> schrieb:
I want to make a program that moves files from a main directory to a
sub directory.
Suggeset that i have 2000 files, the program will create 4 sub
directory's and move 500 files to each directory.

I think until this point it wont be a problem, but.... I want the
files to be ordered by filesize.


You can adapt the code contained in the following post:

<URL:http://groups.google.com/groups?selm...K2MSFTNGP10.ph
x.gbl>

The length of a file can be determined with 'FileLen' or 'FileInfo.Length'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3
There is an excellent example in Microsoft's "Visual Basic.Net Programmer's
Cookbook" under ArrayLists, Sorting. Basically use and array list with a
structure of Filename, filesize, and what everelse you want. Then add the
fileinfo to an arraylist of the structures. Then create a public class the
iimplements IComparer and include a sub the implements
System.Collections.Icomparer.Compare

"Niels" wrote:
Hello,

I want to make a program that moves files from a main directory to a
sub directory.
Suggeset that i have 2000 files, the program will create 4 sub
directory's and move 500 files to each directory.

I think until this point it wont be a problem, but.... I want the
files to be ordered by filesize.
I mean that the first 500 files that will be moved will have the
smallest filesize and so on.

I dan't know if it is possible and ofcourse how to do it...

Is there anyone who can provide me a solution or a push in the good
direction???

Thanks in advance

Nov 21 '05 #4
Thank you all for your reply,

I hoped it would be easyer (i'am still a beginner)and i dont
understand what to do (I have tried different to apply the things you
guys gave to me, but it is still to difficult for me).
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Paul | last post by:
Hi all I have a sorting problem, but my experience with Python is rather limited (3 days), so I am running this by the list first. I have a large database of 15GB, consisting of 10^8 entries...
40
by: Elijah Bailey | last post by:
I want to sort a set of records using STL's sort() function, but dont see an easy way to do it. I have a char *data; which has size mn bytes where m is size of the record and n is the...
0
by: Alex Vinokur | last post by:
=================================== ------------- Sorting ------------- Comparative performance measurement =================================== Testsuite : Comparing Function Objects to...
0
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another...
25
by: Dan Stromberg | last post by:
Hi folks. Python appears to have a good sort method, but when sorting array elements that are very large, and hence have very expensive compares, is there some sort of already-available sort...
4
by: FBM | last post by:
Hi, I am working on a program that simulates one of the elements of ATM. The simulation stores events which occurs every some milliseconds for a certain amount of time. Every time that an event...
10
by: Sjaakie | last post by:
Hi, I'm, what it turns out to be, fooling around with 3-tier design. At several websites people get really enthusiastic about using custom dataobjects instead of datasets/-tables. While trying to...
12
by: bisuvious | last post by:
hi all, I am looking for a technique to sort data of a large file, say 2GB/ 4GB. Please suggest any algorithm, if you have any idea. thanks bisuvious
11
by: Trent | last post by:
Running this I see that on first run, both bubble and selection sort have 9 sort counts while insertion sort has ZERO. With a sorted list, should this be ZERO for all? Also bsort and Ssort have...
4
by: Trent | last post by:
Still have problems with this thing. Seems my results are not matching the "correct" example given. The three sets of numbers below the last 3 columns is suppose to be the number of comparisons...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.