Janis Papanagnou wrote:
> On 12.08.2022 03:21, Tuxedo wrote:
[...]
>
> The filename is (e.g.) "MAH0011.MP4" but you want "MAH0011", it seems.
> Stripping any extension might not lead to sensible filenames, depending
> on the naming rule. - Consider how files should be displayed, e.g.,
> "f.tar.gz", or ".sh_profile", etc.
You're right. It's best not to hide the file extensions.
>
>> append '</a>' after the filename
>>
>> How can this be done using any combination of commands and constructs?
>
> One way can be along this principle approach...
>
> locate -i .mp4 |
> xargs stat -c'%Y <a href=%n>%n</a>' |
> sort -n |
> cut -d' ' -f2- |
> sed 's/>[^<]\+\/\(.*\)[.][^.]\+</>\1</'
>
> Here the stat command will add modification time in seconds since Epoch,
> sort will do the numerical sorting of the entries, cut strips off that
> seconds field again, and sed will remove the unwanted parts from the
> file-path that will be visible in the HTML output.
>
> Specifically the sed expression may be adjusted, depending on what the
> "filename" actually shall be (see note on top).
Thanks for the stat, sort and sed tricks!
It outputs a list of the file name portions within the <a
href=linkpath">filename</a>
But, as said, it's better to include the file extensions in the output.
Systems which typically hide file extensions are for users who get confused
by them.
Can anyone here also suggest how to include a part of the file path in the
link name to add a visual indication of the whereabouts of each file in the
HTML list output, something like follows:
<a href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a>
This presumes all is somewhere in ~/ although it's not. Replacing the
/home/tuxedo string with /~ is just meant to shorten the output a little.
Before the link, how can a date stamp best be added?
As in:
Dec 14 2018 <a
href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a>
Or maybe:
2018-12-14
<a href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a>
And after the link, how can the file sizes be added to the final output?
As in "YY-MM-DD <a..>file.ext</a> (size)":
2018-12-14
<a href=/home/tuxedo/some/dir/MAH0045.MP4>~/some/dir/MAH0045.MP4</a> (15MB)
Or the size can appear before or between the date and file name. It doesn't
really matter as long as it's somewhere.
Thanks for any additional ideas!
Tuxedo
>
> Janis
>
>
>>
>> Many thanks,
>> Tuxedo
>>