Shuffling the .XnViewSort file

Ideas for improvements and requests for new features in XnView MP

Moderators: XnTriq, xnview

Post Reply
marsh
XnThusiast
Posts: 2443
Joined: Sun May 15, 2005 6:31 am

Shuffling the .XnViewSort file

Post by marsh » Fri Feb 26, 2010 2:25 am

Can anyone recommend a text tool to shuffle the filenames in the 'sort' file?

User avatar
JohnFredC
XnThusiast
Posts: 2010
Joined: Wed Mar 17, 2004 8:33 pm
Location: Sarasota Florida

Re: Shuffling the .XnViewSort file

Post by JohnFredC » Fri Feb 26, 2010 4:56 pm

Hi Marsh...

Here is one. It is a command-line utility to sort text files.

It will optionally skip the header-line (required for .XnSortFile), sort on any substring, etc.
John

marsh
XnThusiast
Posts: 2443
Joined: Sun May 15, 2005 6:31 am

Re: Shuffling the .XnViewSort file

Post by marsh » Fri Feb 26, 2010 10:14 pm

Thanks. To complement ordering, I discovered a Linux program called shuf (which was already built into OS) to create a random listing. I'm launching the following script from my file manager. After refresh, the new arrangement appears.

Code: Select all

#!/bin/sh
#
# Randomize .XnViewSort file and add header
#
for i in "$*"; do
    shuf "$i" -o "$i"
    grep -v -E 'XnView sort' "$i" >xnfilenames.txt
    echo "XnView sort" > xntemp.txt
    cat xnfilenames.txt >> xntemp.txt
    cp xntemp.txt "$i"
done

User avatar
JohnFredC
XnThusiast
Posts: 2010
Joined: Wed Mar 17, 2004 8:33 pm
Location: Sarasota Florida

Re: Shuffling the .XnViewSort file

Post by JohnFredC » Sat Feb 27, 2010 1:02 am

Ah yes... Linux. The tool I suggested is Windows only.
John

marsh
XnThusiast
Posts: 2443
Joined: Sun May 15, 2005 6:31 am

Re: Shuffling the .XnViewSort file

Post by marsh » Sun Feb 28, 2010 5:11 am

Some win32 versions of linux utilities are available here.
This playlistmixer.bat works with emulator... don't know about actual OS.

Code: Select all

grep -v -E "XnView sort" .XnViewSort >filenames.tmp
sort-7.6.exe -R -o scrambled.tmp filenames.tmp
echo XnView sort >header.tmp
cat scrambled.tmp >> header.tmp
copy header.tmp .XnViewSort
rem del *.tmp
Programs used:
grep.exe, sort-7.6.exe, cat.exe
Requirements:
libiconv2.dll, libintl3.dll, msvcp60.dll, pcre3.dll, regex2.dll

Thoughts about MP:
These examples might help determine the usefulness of scrambling order before vs. after switching to the "custom" sort.

Post Reply