I started working on a gAWK script, to help create web page from UI to view on web browser.
Actually, the script only search and duplicate with new extension all files with extension .rml and .rcss to make .html and .css respectively.
This script intend to be run in /pkg/unvanquished_src.dpkdir/ui/
Code: Select all
#!/bin/awk
# By SuperDupont
# 2022.02.16
# Work in progress
# Version 0.2
# Licence : Creative Commons Attribution Share Alike
function namefile(file) {
sub(".*/", "", file)
return file
}
function notlastpart(path,delimit) { # This function is used by pathfile and extname
# init
split("",tab)
split(path,tab,delimit)
path = ""
#The last part won't be keep
for (i=1;i<=length(tab)-1;++i){
path = path tab[i] delimit
}
return path
}
function pathfile(file) {
return notlastpart(file,"/")
}
function extname(file) {
return notlastpart(file,".")
}
function searchingfile(ext) {
# init
split("",listfiles)
print "Searching files... (*." ext ")"
cmd = "find . -type f -iname '*." ext "' -printf '%h/%f;'"
cmd | getline liste ; close("cmd")
split(liste,lfiles,";")
for (indexvar in lfiles) {
realpath = lfiles[indexvar]
if (realpath != "") {
print "Preparing file ",indexvar," : ",realpath
listfiles[indexvar] = realpath
}
}
return
}
function copy2ext(file,ext) {
filename = namefile(file)
shortname = extname(filename)
path = pathfile(file)
target = path shortname ext
print "$: cp " file " -> " target
cmd = "cp " file " " target
system(cmd)
}
BEGIN{
#print "Searching files... (*.rml *.rcss)"
# Les tableaux des fichiers rml et rcss
# cmd = "find . -type f -iname '*.rml' -printf '%h/%f;'"
# cmd | getline liste ; close("cmd")
searchingfile("rml")
print "Copying files with new extension"
for (indexvar in listfiles) {
file = listfiles[indexvar]
print "file ",indexvar," : ",file
copy2ext(file,"html")
}
searchingfile("rcss")
print "Copying files with new extension"
for (indexvar in listfiles) {
file = listfiles[indexvar]
print "file ",indexvar," : ",file
copy2ext(file,"css")
}
exit
}
#=patern={
#}
END{
}