Difficult to sort
-
Came across a folder having files with these names: Eighth.txt Eleventh.txt Fifth.txt First.txt Fourth.txt Ninth.txt Second.txt Seventh.txt Sixth.txt Tenth.txt Third.txt Not easy to sort :-(
-
Came across a folder having files with these names: Eighth.txt Eleventh.txt Fifth.txt First.txt Fourth.txt Ninth.txt Second.txt Seventh.txt Sixth.txt Tenth.txt Third.txt Not easy to sort :-(
No need to: they are already sorted alphabetically!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Came across a folder having files with these names: Eighth.txt Eleventh.txt Fifth.txt First.txt Fourth.txt Ninth.txt Second.txt Seventh.txt Sixth.txt Tenth.txt Third.txt Not easy to sort :-(
nah, easy !
-
Came across a folder having files with these names: Eighth.txt Eleventh.txt Fifth.txt First.txt Fourth.txt Ninth.txt Second.txt Seventh.txt Sixth.txt Tenth.txt Third.txt Not easy to sort :-(
- Select ALL 2) Delete Where's the problem? :)
New version: WinHeist Version 2.1.0 My goal in life is to have a psychiatric disorder named after me. I'm currently unsupervised, I know it freaks me out too but the possibilities are endless.
-
Came across a folder having files with these names: Eighth.txt Eleventh.txt Fifth.txt First.txt Fourth.txt Ninth.txt Second.txt Seventh.txt Sixth.txt Tenth.txt Third.txt Not easy to sort :-(
Sorting them will be easy! All you need to sort them is meta-data, so just go to http//:yetmoreuselessxmlcrap.com and download our XML-based system! All your current worries will simply fade into the background, as you spend the next five years setting up the system to handle this simple task!!
I wanna be a eunuchs developer! Pass me a bread knife!
-
Came across a folder having files with these names: Eighth.txt Eleventh.txt Fifth.txt First.txt Fourth.txt Ninth.txt Second.txt Seventh.txt Sixth.txt Tenth.txt Third.txt Not easy to sort :-(
Why? Because you only have ten fingers? ;)
Anything that is unrelated to elephants is irrelephant
Anonymous
-----
The problem with quotes on the internet is that you can never tell if they're genuine
Winston Churchill, 1944
-----
I'd just like a chance to prove that money can't make me happy.
Me, all the time -
No need to: they are already sorted alphabetically!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
Nah ... You know what I mean :-)
-
Nah ... You know what I mean :-)
Easy: sort by creation date...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Easy: sort by creation date...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
For some strange / unknown reason, the creation time is the same, to the level of second. And the files are modified in different orders by different people, and we cannot use the 'Date of Modification' also.
-
Came across a folder having files with these names: Eighth.txt Eleventh.txt Fifth.txt First.txt Fourth.txt Ninth.txt Second.txt Seventh.txt Sixth.txt Tenth.txt Third.txt Not easy to sort :-(
I'd be a bully and rename them to 01.txt ... 11.txt, or 01st.txt to 11th.txt
-
- Select ALL 2) Delete Where's the problem? :)
New version: WinHeist Version 2.1.0 My goal in life is to have a psychiatric disorder named after me. I'm currently unsupervised, I know it freaks me out too but the possibilities are endless.
-
Came across a folder having files with these names: Eighth.txt Eleventh.txt Fifth.txt First.txt Fourth.txt Ninth.txt Second.txt Seventh.txt Sixth.txt Tenth.txt Third.txt Not easy to sort :-(
Here, I solved this with C# and Linqpad. Here are the steps: 1. Get LINQPad at http://www.linqpad.net/[^] It's a great free tool which allows you to run C# as a script 2. Copy the code below to LINQPad 3. Change the <yourPathToFiles> to the path to your files. 4. run Notice that it uses an enumeration to set the value automatically of each string ("first", "second", etc) to a numeric value. After that it adds the file names to the SortedList and then prints them out. Easy as that. If you need other FileInfo about those files, it would be very easy to add. This'll get you started. The number one thing about this is, GET LINQPAD. It is a great tool.
void Main()
{
string [] allFiles = Directory.GetFiles(@"C:\","*.txt");
SortedList allFileNames = new SortedList();
order fileSortOrder = new order();
foreach (string filename in allFiles)
{
string tempName = Path.GetFileNameWithoutExtension(filename);
allFileNames.Add(Enum.Parse(fileSortOrder.GetType(),tempName), Path.GetFileName(filename));
}
for (int i=0; i< allFileNames.Count;i++)
{
Console.WriteLine(allFileNames.GetByIndex(i));
}
}enum order
{
first,
second,
third,
fourth,
fifth,
sixth,
seventh,
eighth,
ninth,
tenth,
eleventh
}OUTPUT
first.txt
second.txt
third.txt
fourth.txt
fifth.txt
sixth.txt
seventh.txt
eighth.txt
ninth.txt
tenth.txt
eleventh.txt -
Here, I solved this with C# and Linqpad. Here are the steps: 1. Get LINQPad at http://www.linqpad.net/[^] It's a great free tool which allows you to run C# as a script 2. Copy the code below to LINQPad 3. Change the <yourPathToFiles> to the path to your files. 4. run Notice that it uses an enumeration to set the value automatically of each string ("first", "second", etc) to a numeric value. After that it adds the file names to the SortedList and then prints them out. Easy as that. If you need other FileInfo about those files, it would be very easy to add. This'll get you started. The number one thing about this is, GET LINQPAD. It is a great tool.
void Main()
{
string [] allFiles = Directory.GetFiles(@"C:\","*.txt");
SortedList allFileNames = new SortedList();
order fileSortOrder = new order();
foreach (string filename in allFiles)
{
string tempName = Path.GetFileNameWithoutExtension(filename);
allFileNames.Add(Enum.Parse(fileSortOrder.GetType(),tempName), Path.GetFileName(filename));
}
for (int i=0; i< allFileNames.Count;i++)
{
Console.WriteLine(allFileNames.GetByIndex(i));
}
}enum order
{
first,
second,
third,
fourth,
fifth,
sixth,
seventh,
eighth,
ninth,
tenth,
eleventh
}OUTPUT
first.txt
second.txt
third.txt
fourth.txt
fifth.txt
sixth.txt
seventh.txt
eighth.txt
ninth.txt
tenth.txt
eleventh.txtSolves for the known set, but what about twelfth.txt, thirteenth.txt, etc?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Solves for the known set, but what about twelfth.txt, thirteenth.txt, etc?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013John Simmons / outlaw programmer wrote:
Solves for the known set, but what about twelfth.txt, thirteenth.txt, etc?
That is a great question. If the user had more of those crazy file names, he can simply add the names to the enum and it will work. You may say to that, "well, there could be hundreds of these". Yes, and for that we could use the
Directory.GetFiles()
andPath.GetFileNameWithoutExtension
to gen a comma delimited list and save it to a file, then just copy the list to the enumeration and that part would be done too. It's a bit clunky, but it does work. :) EDIT: Oops I think I fell into a loop of thinking here. :-O Actually, when you use Directory.GetFiles and got the names, they wouldn't be sorted properly to add to the enum so we are back at the beginning challenge. The sort is all based upon the enum being in order since an enum's values are then in ascending order by default. -
John Simmons / outlaw programmer wrote:
Solves for the known set, but what about twelfth.txt, thirteenth.txt, etc?
That is a great question. If the user had more of those crazy file names, he can simply add the names to the enum and it will work. You may say to that, "well, there could be hundreds of these". Yes, and for that we could use the
Directory.GetFiles()
andPath.GetFileNameWithoutExtension
to gen a comma delimited list and save it to a file, then just copy the list to the enumeration and that part would be done too. It's a bit clunky, but it does work. :) EDIT: Oops I think I fell into a loop of thinking here. :-O Actually, when you use Directory.GetFiles and got the names, they wouldn't be sorted properly to add to the enum so we are back at the beginning challenge. The sort is all based upon the enum being in order since an enum's values are then in ascending order by default. -
But then you still have the problem, that you need to sort the comma delimited list manually before you put it into the enum.
The good thing about pessimism is, that you are always either right or pleasently surprised.
I think I was editing as you were replying. :-O Oops, you are right.
-
Here, I solved this with C# and Linqpad. Here are the steps: 1. Get LINQPad at http://www.linqpad.net/[^] It's a great free tool which allows you to run C# as a script 2. Copy the code below to LINQPad 3. Change the <yourPathToFiles> to the path to your files. 4. run Notice that it uses an enumeration to set the value automatically of each string ("first", "second", etc) to a numeric value. After that it adds the file names to the SortedList and then prints them out. Easy as that. If you need other FileInfo about those files, it would be very easy to add. This'll get you started. The number one thing about this is, GET LINQPAD. It is a great tool.
void Main()
{
string [] allFiles = Directory.GetFiles(@"C:\","*.txt");
SortedList allFileNames = new SortedList();
order fileSortOrder = new order();
foreach (string filename in allFiles)
{
string tempName = Path.GetFileNameWithoutExtension(filename);
allFileNames.Add(Enum.Parse(fileSortOrder.GetType(),tempName), Path.GetFileName(filename));
}
for (int i=0; i< allFileNames.Count;i++)
{
Console.WriteLine(allFileNames.GetByIndex(i));
}
}enum order
{
first,
second,
third,
fourth,
fifth,
sixth,
seventh,
eighth,
ninth,
tenth,
eleventh
}OUTPUT
first.txt
second.txt
third.txt
fourth.txt
fifth.txt
sixth.txt
seventh.txt
eighth.txt
ninth.txt
tenth.txt
eleventh.txtWow. I'll get LINQPad.
-
Here, I solved this with C# and Linqpad. Here are the steps: 1. Get LINQPad at http://www.linqpad.net/[^] It's a great free tool which allows you to run C# as a script 2. Copy the code below to LINQPad 3. Change the <yourPathToFiles> to the path to your files. 4. run Notice that it uses an enumeration to set the value automatically of each string ("first", "second", etc) to a numeric value. After that it adds the file names to the SortedList and then prints them out. Easy as that. If you need other FileInfo about those files, it would be very easy to add. This'll get you started. The number one thing about this is, GET LINQPAD. It is a great tool.
void Main()
{
string [] allFiles = Directory.GetFiles(@"C:\","*.txt");
SortedList allFileNames = new SortedList();
order fileSortOrder = new order();
foreach (string filename in allFiles)
{
string tempName = Path.GetFileNameWithoutExtension(filename);
allFileNames.Add(Enum.Parse(fileSortOrder.GetType(),tempName), Path.GetFileName(filename));
}
for (int i=0; i< allFileNames.Count;i++)
{
Console.WriteLine(allFileNames.GetByIndex(i));
}
}enum order
{
first,
second,
third,
fourth,
fifth,
sixth,
seventh,
eighth,
ninth,
tenth,
eleventh
}OUTPUT
first.txt
second.txt
third.txt
fourth.txt
fifth.txt
sixth.txt
seventh.txt
eighth.txt
ninth.txt
tenth.txt
eleventh.txtTrust a c#er to come up with a needlessly complex solution. Create a file: list.bat with the following content
echo first.txt
echo second.txt
echo third.txt
echo fourth.txt
echo fifth.txt
echo sixth.txt
echo seventh.txt
echo eighth.txt
echo ninth.txt
echo tenth.txt
echo eleventh.txtQED (Quite Easily Done)! You don't even need a programmer if they create more files - just a text editor. Sorted - I'll go and help Griff make coffee now (poor old sod needs help!)
Life is like a s**t sandwich; the more bread you have, the less s**t you eat.
-
Trust a c#er to come up with a needlessly complex solution. Create a file: list.bat with the following content
echo first.txt
echo second.txt
echo third.txt
echo fourth.txt
echo fifth.txt
echo sixth.txt
echo seventh.txt
echo eighth.txt
echo ninth.txt
echo tenth.txt
echo eleventh.txtQED (Quite Easily Done)! You don't even need a programmer if they create more files - just a text editor. Sorted - I'll go and help Griff make coffee now (poor old sod needs help!)
Life is like a s**t sandwich; the more bread you have, the less s**t you eat.
But...I love needless complexity. My coffee makes itself with C#. :rolleyes:
-
But...I love needless complexity. My coffee makes itself with C#. :rolleyes:
That reminds me of my first Oracle night school lesson. The guy next to me was doing something excessively complicated, so I said (genuinely not understanding) "Why do it that way instead of x?" He replied "Because I can!" The lecturer then made some disparaging remarks about programmers!
Life is like a s**t sandwich; the more bread you have, the less s**t you eat.