Shuffling the .XnViewSort file

Ideas for improvements and requests for new features in XnView MP

Moderators: helmut, XnTriq, xnview

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

Shuffling the .XnViewSort file

Post by marsh »

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 »

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 »

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 »

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 »

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