Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
fishmech
Jul 16, 2006

by VideoGames
Salad Prong
I'm looking for a Windows application that will randomly reorder the lines in a specified text file and save the resulting text to optionally either the original file or a new file. It'd be a bonus if it was possible to have it randomize "more" or "less" on a slider, kind of like how Winamp's shuffle function has the ability to choose tracks more in the order they exist in a playlist or more completely random.

Adbot
ADBOT LOVES YOU

fishmech
Jul 16, 2006

by VideoGames
Salad Prong

Thermopyle posted:

Can it be command line?

How large are these text files?

Command line is fine, and the biggest I want to do is about 20 kilobytes in like 5000 lines.

fishmech
Jul 16, 2006

by VideoGames
Salad Prong

Hoborg posted:

Here y'go:

Here's a chart showing how different values of of d result in a distribution that closer resembles the original file.



(the trendlines show the distribution of data points, the closer it is to a gradient of 1.0 then the closer it matches the original file).

Here's the program source and compiled binary:

Binary: http://bit.ly/fSzynh
Source: http://bit.ly/ihhLxy

To run:

Double-click and it'll give you a File Open Dialog to choose the source file. After that it'll give you a Save File Dialog to choose where to save the file, you can overwrite the source file if you want or save to a new file. After that you'll be prompted for a floating-point number between 0 and 1.0 to choose the randomness. Choose 0 for a file that matches the original, 1.0 for a completely random file. For 'semi-random' choose something around 0.25.

It also had optional command-line arguments. You can specify either two or three arguments:

Hob.RandomReorderFile <sourceFileName> <destinationFileName> [randomness]

(where randomness is a floating point number from 0 to 1.0)

Enjoy.

(I'd appreciate any and all feedback).

Oh sweet that works awesome! Thanks for the work man.

fishmech
Jul 16, 2006

by VideoGames
Salad Prong
I need a program that can clean up my Kindle. Here's what I mean:

When you read a book on the kindle, it makes a matching folder in the same folder as the book file is, with a matching name. As an example:
For the book at F:\documents\Alien Emergencies_ A Sector General Omnibus_B003J5UJ72.azw it creates a folder F:\documents\Alien Emergencies_ A Sector General Omnibus_B003J5UJ72.sdr that contains metadata and a way to mark your progress in your book.

It's supposed to delete the "sidecar" folder when you delete the book on the device, but it doesn't always do it, and the device gets cluttered with these over time. And since there's only like 3 GB of storage on it hundreds of folders at 200 KB to 2 MB does add up.

What I'd like is a program that finds all folders with a name ending with ".sdr" in a given folder and its subfolders, and looks for any matching file of the extensions ".azw", ".mobi", ".txt", ".pdf", ".prc", ".pdb", ".azw1" or ".azw3". If the program can't find a match, it should move the ".sdr" folders to another folder where they can then be manually deleted.

The program should be able to run on Windows 7 or later, but if it's easier to make it just run on Windows 10 that's fine too.

fishmech
Jul 16, 2006

by VideoGames
Salad Prong

mobby_6kl posted:

Sorry things got a bit busy. Here you go:

KindleKleaner

Just copy the executable to the base directory (like F:\documents) and run it from there. It'll move all orphaned .sdr files to a new subfolder called ".SDRs". It's not checking for any specific extensions, just anything else, let me know if that's a problem. Folders starting with a dot (.) are skipped. Also I tested it on my own system but it very well can delete everything and send me your bitcoins, so your own risk etc.

The program only moves .sdr files, when it needs to also move folders that are named *.sdr Not sure how to change that in the source code myself, otherwise I just would.

It has managed to clean up some older problem files already though so that already helps a bit!

fishmech
Jul 16, 2006

by VideoGames
Salad Prong

mobby_6kl posted:

Oh wow, somehow I missed that those are folder and not files, even though you explicitly say so in several places. Probably has something to do with reading the requirements at 1:30am :v:

I'll change it so that it moves the "Book2.sdr" folder and everything in.
Book1.txt
Book1.sdr\abc.xyz
Book2.sdr\def.xyz

Yeah that'll work fine. Thanks for the work!

Adbot
ADBOT LOVES YOU

fishmech
Jul 16, 2006

by VideoGames
Salad Prong

mobby_6kl posted:

So that was super straightforward to change but I don't blame you for not messing with that code, it's... a bit sketchy :)

KindleKleaner

Just used it and it worked perfectly! And my Kindle now has 300 fewer junk folders and about 200 MB of space was recovered. Thanks a lot!

  • Locked thread