Recursive alpha sort the contents of selected files/folde

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
lukescammell
Posts: 744
Joined: 28 Jul 2006 13:15
Location: Kent, UK
Contact:

Recursive alpha sort the contents of selected files/folde

Post by lukescammell »

I have a kind of general text manipulation question, but I know how good some of your xy scripting gurus are, so I figured it was worth asking here. Of course, if there’s a better tool for the job, I’d be equally happy to be pointed in the right direction.

I would like to alpha sort the lines (contents) of all the files in a folder, or selection of files and folders, recursively.

Is xyscripting a sensible way to approach this? If so, would anyone be kind enough to write this? This is for a mobile game wiki that I edit and not for any kind of business application (though I’m sure someone would find it useful for that).

Thanks!

Edit: after the file contents have been alphabetised, I then feed them through BeyondCompare to find out what has changed between versions of the game so I can update the wiki…
Used to update to the latest beta every day. Now I have children instead…
Windows 10 Pro x64 (everywhere except phone…)

highend
Posts: 13308
Joined: 06 Feb 2011 00:33

Re: Recursive alpha sort the contents of selected files/fold

Post by highend »

Foreach loop over all selected files
Readfile to get the content
Formatlist the content recursively
Writefile the new content back

On vacation no time to write real code...
One of my scripts helped you out? Please donate via Paypal

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Recursive alpha sort the contents of selected files/fold

Post by TheQwerty »

FYI, Beyond Compare can perform the sorting for you.

First ensure you have a "Sorted" format defined under Tools > File Formats... (included by default in BC 4):
2016-10-03 075541.png
2016-10-03 075541.png (60.77 KiB) Viewed 1380 times
Then when you're comparing files there's a drop-down that you can use to select "Sorted" comparison (EDIT: You must do this in each pane.):
2016-10-03 080057.png
2016-10-03 080057.png (40.37 KiB) Viewed 1380 times
If you wanted to have BC automatically apply the sorting you could configure the Sorted format's General > Mask field to match your files.

-----------------
Also, while XY scripting can be used to sort the files, Windows ships with a sort program which might be a better choice.


Hope that helps!

lukescammell
Posts: 744
Joined: 28 Jul 2006 13:15
Location: Kent, UK
Contact:

Re: Recursive alpha sort the contents of selected files/fold

Post by lukescammell »

I do have a licence for BC4, so I will probably use that. Interesting about Sort! Thanks for everyone's help, I knew this would be the place to get answers ;)
Used to update to the latest beta every day. Now I have children instead…
Windows 10 Pro x64 (everywhere except phone…)

Post Reply