General TC > Programming & Scripting - Unofficial
Script for retrieving selected fields from .tcz.info files
(1/1)
Rich:
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:
--- Quote --- ... the current info files are intended for human consumption as plain text
not for programmatic / machine readability & processing ...
--- End quote ---
and
--- Quote --- ... Yes, adopting a standard would increase machine readability. ...
--- End quote ---
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:
--- Code: ---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
--- End code ---
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:
--- Code: ---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
--- End code ---
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:
--- Code: ---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
--- End code ---
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:
--- Code: ---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
--- End code ---
Script is attached.
gadget42:
a new test subject for the holiday seasons! tx rich!
mocore:
--- Quote from: gadget42 on December 23, 2024, 06:30:32 AM ---a new test subject for the holiday seasons! tx rich!
--- End quote ---
+1 ... https://forum.tinycorelinux.net/index.php/topic,27467.msg176890.html#msg176890
Navigation
[0] Message Index
Go to full version