This script was inspired by a thread that talked about handling .info files.
What the planned endgame there is, I still don't know.
I did find these statements a bit disturbing:
... the current info files are intended for human consumption as plain text
not for programmatic / machine readability & processing ...
and
... Yes, adopting a standard would increase machine readability. ...
It sounds like the idea is to make life easier for computers and more difficult
for people creating the .info file.
Anyway, here's how it works:
tc@E310:~/Scripting/RepoScripts/ParseInfoFile$ ./ParseInfoFile.sh PicFormat Title Version Current Size
Title: PicFormat.tcz
Version: v0.20
Current: 2021/07/16 v0.20 Added -p resize option.
Size: 8.0K
Give it the file name and field names you are interested in, and it returns their
contents in the same order requested. File name can be Filename, Filename.tcz, or
Filename.tcz.info and the script will correct it to Filename.tcz.info. The .info must
be present on your machine. The script does not connect to the repo for it.
If you want the field name on a separate line:
tc@E310:~/Scripting/RepoScripts/ParseInfoFile$ ./ParseInfoFile.sh PicFormat -s Title Version Current Size
Title:
PicFormat.tcz
Version:
v0.20
Current:
2021/07/16 v0.20 Added -p resize option.
Size:
8.0K
Some other options include a count of how many field names are in the file, a
list of all of the field names in the file, and a list of all field names and their
starting and ending line numbers:
tc@E310:~/Scripting/RepoScripts/ParseInfoFile$ ./ParseInfoFile.sh PicFormat -i
Title.1,1
Description.2,2
Version.3,3
Author.4,4
Original-site.5,5
Copying-policy.6,6
Size.7,7
Extension_by.8,8
Tags.9,9
Comments.10,44
Change-log.45,45
Current.46,46
This is also the order the field names appear in the file.
The field names are not hard coded in the script. They are obtained by scanning
the file in question.
There is also a help message:
tc@E310:~/Scripting/RepoScripts/ParseInfoFile$ ./ParseInfoFile.sh -h
Version 0.1 Dec 22, 2024
This script is used to find and display labels and their contents
from a .tcz.info file. Options must be listed separately, -e -s, not -es.
Usage:
ParseInfoFile.sh filename [ -n -l -i -s -e ] Label1 Label2 Label3 ...
-n Display number of labels in info file.
-l List the labels found in info file.
-i Like l but includes start/end line numbers for label.
-s Place label on a separate line.
-e Extra linefeed between label results.
Labels will be listed in the order requested, example:
ParseInfoFile.sh PicFormat Title Current Size
Title: PicFormat.tcz
Current: 2021/07/16 v0.20 Added -p resize option.
Size: 8.0K
Script is attached.