dam/src/print_trackids_to_imageids
ayakael 72aac8134f
Deprecations in favour of changes in deployment workflow:
[is_selected] Deprecated (and exterminated)
[deploy_imageid] Deprecated in favor of deploy_cp, deploy_rm and deploy_meta
[deploy_trackid] Deprecated in favor of deploy_cp, deploy_rm and deploy_meta

Misc changes and bugfixes for print functions
[print_future_path] In the event that TITLE is not set, TITLE will now be ALBUM, for tracks without titles.
[print_meta_flac] Track TITLES with colons are now kept
[print_present_path] Now needs IMAGEID and TRACKID in argument for TRACKID wasn't unique enough
[print_trackids_to_imageids] Prints the IMAGEIDs of all TRACKIDs

New functions for new deployment workflow that allows for deletion first, copying later, and smarter metadata adjustments
[deploy_rm] Removes all given TRACKIDs (i.e, what FILE_DB defines as false, but target_dir is not null)
[deploy_cp] Function copies TRACKIDs on a IMAGEID by IMAGEID basis to TARGET
[deploy_meta] Function applies metadata to IMAGEID tracks
[cmd_deploy] Rewrote cmd_deploy for use of new deploy functions

Bug fixes to db selections and db update
[db_set] Now ignores all lines that have LAST_DEPLOY and LAST_UPDATE
[db_update] Added function to report a file as removed from git dir. (null in selection column)
[cmd_update] LAST_COMMIT is now LAST_UPDATE in favour of LAST_DEPLOY, which is for commit of when last deployment occured
[cmd_update] Gawk is now used for inplace editing of database

Misc. adjustements
[cmd_deploy] Rewrote disk usage check
2018-04-06 18:55:34 -04:00

28 lines
834 B
Bash

#!/bin/bash
# doc print_trackids_to_imageids {
#
# DESCRIPTION
# print_trackids_to_imageids - Prints the IMAGEIDs of all TRACKIDs.
#
# USAGE
# print_trackids_to_imageids </path/to/db/file> <TRACKID_1> [<...>]
#
# }
print_trackids_to_imageids() {
## Argument parsing
local DB_FILE="${1}"; shift
local trackidList=(${@})
## Prints imageid of trackid if trackidList has only 1 element
[[ ${#imageidList[@]} -eq 1 ]] && { awk -v trackid=${trackid} 'BEGIN{FS="\t"}{if($3==trackid){print $2}}' ${DB_FILE}; return 0; }
## Generates imageidList
for trackid in ${trackidList[@]}; do
local imageidList=(${imageidList[@]} $(awk -v trackid=${trackid} 'BEGIN{FS="\t"}{if($3==trackid){print $2}}' ${DB_FILE}))
done
awk '!seen[$0]++' <<<$(printf "%s\n" ${imageidList[@]})
return 0
}