[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] Iterate over folders/files, suming sizes until limit
From: |
Roger |
Subject: |
[bug-gawk] Iterate over folders/files, suming sizes until limit |
Date: |
Sun, 23 Jun 2019 12:06:18 -0400 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
Well, I read the AWK/GAWK book ~10 years ago, and now have my first official
use for AWK! However, it's now Summer and am significantly rusty with skills.
Since this is the only mailing list, and the description states, "... and
everything else", I'll post my inquiry here.
Summary: Need to list files/folders for recording to DVD/BD-R media, with a one
line list of folders/files for passing to growisofs or mkisofs, limiting to
media size. (I'm really surprised nobody has something remotely completed,
seemingly everyone rely upon the graphical front-ends! The folders contain
multiple surveillance audio/video files.)
Steps: Iterate over the current contents of a folder using "/bin/du", at a
specified limit (eg. 46.5GB for 50GB BD-R media, adding the folder sizes until
accumulated size is ~46.5GB) print a one line list of folders (for passing
manually to growisofs), then continue repeating the previous commands until no
more folders/files.
This sounds like a simple and desired (database field sum) task for AWK, but
likely requiring data from "du".
The initial output will likely be:
"./20170711 ./20170712 ./20170713 ./20170714",
However I need to further format to mkisofs "-graft-points" feature:
"20170711=./20170711 20170712=./20170712 20170713=./20170713
20170714=20170714/"
Just need a little hand holding here as my skills are extremely rusty.
I can imagine a slightly modified AWK program using "/bin/ls" for only files
instead of "/bin/du" for just folders, or both. I already have part of my
problems solved, using "du -kh --max-depth=1 |sort -k 2" to find folder size
and sort according to the year_month_dated folder names.
I could likely easily whip-up one of my excellently written Bash scripts with
"/bin/du" outputted temporary file to the /tmp folder without bugging anybody,
but figure it's probably best/proper to do this all in AWK/GAWK script and have
something posted for public use.
Roger
- [bug-gawk] Iterate over folders/files, suming sizes until limit,
Roger <=