MeshChat running on a Raspberry Pi (RPI) can have many files in the Files section that users can see and download. For me, I wanted to do a alphanumeric sort based on the file names but that is not part of the MeshChat application as it nicely puts the file listing in order of first-to-last stored. I made a work-around that can be used. It is a bash script that the RPI sysop can run to change all the date-stamps for the files.
The script creates a command script that when executed changes each file one at a time with a new date-stamp. If the script is aborted, the created command script remains and can be examined or run by itself.
I'm not a programmer so posting of improvements are welcomed.
Just another comment: I tried to create a directory in the Files section but it appears MeshChat will not support such a file tree structure. (Maybe a work-around can be made for that?) For me this further emphasizes the importance of alphanumeric sorting.
I thought there was a way to attach a file but I cannot find it so here it is below. The name I used for the script is ".ChangeAllFileDateStamps". The dot-file names will not get sorted nor will they show up on the MeshChat Files listing.
73 Mike, AB4YY
73 Mike, AB4YY
#!/bin/bash
# This script will do reverse sort of all files then
# will create a script that can be run to actually
# change the date stamps of all files. This was
# created to give a nice alphanumeric sort of the
# MeshChat Files that users see.
# Change directory to where the files are located:
# "cd /var/www/html/meshchat/files"
# Finally use sudo to run this script.
# First check that this is being run as sudo if not then exit.
if [[ $EUID -ne 0 ]]; then
echo "Please re-run this script as root (sudo ./.ChangeAllFileDateStamps)"
exit 1
fi
> .temp
> .ReDateStampAllFiles
for file in *
do
echo "touch " $file ";" "sleep 1" >> .temp
done
# make command scrip echo its ouput
echo "#!/bin/sh -x" >> .temp
# now reverse order of lines
sed '1!G;h;$!d' .temp > .ReDateStampAllFiles
# cleanup by deleting .temp file
rm ./.temp
# make the command script executable
chmod +x .ReDateStampAllFiles
echo "Executable script named \".ReDateStampAllFiles\" has been created."
echo ""
read -n 1 -s -r -p "Press any key to CHANGE DATE STAMPS IN ALL FILES IN THIS DIRECTORY! or CTRL-C to Abort!"
echo ""
read -n 1 -s -r -p "LAST CHANCE!!! Press any key to CHANGE DATE STAMPS IN ALL FILES IN THIS DIRECTORY! or CTRL-C to Abort!"
echo ""
echo "You hit any key!"
./.ReDateStampAllFiles
# cleanup by deleting .ReDateStampAllFiles file
rm .ReDateStampAllFiles