Page 1 of 1

Shuffling the .XnViewSort file

Posted: Fri Feb 26, 2010 2:25 am
by marsh
Can anyone recommend a text tool to shuffle the filenames in the 'sort' file?

Re: Shuffling the .XnViewSort file

Posted: Fri Feb 26, 2010 4:56 pm
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.

Re: Shuffling the .XnViewSort file

Posted: Fri Feb 26, 2010 10:14 pm
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

Re: Shuffling the .XnViewSort file

Posted: Sat Feb 27, 2010 1:02 am
by JohnFredC
Ah yes... Linux. The tool I suggested is Windows only.

Re: Shuffling the .XnViewSort file

Posted: Sun Feb 28, 2010 5:11 am
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.