From c9d13e3a259170d4e39ae6911e393bf598d8abc5 Mon Sep 17 00:00:00 2001 From: Mike Holloway Date: Sat, 26 Mar 2022 18:21:04 -0400 Subject: [PATCH] On branch rewrite-2022-03-26 Your branch is up to date with 'origin/rewrite-2022-03-26'. Changes to be committed: modified: hash-files Moving csv file preparation outside per-file loop. --- hash-files | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hash-files b/hash-files index 91afc80..82c3e92 100755 --- a/hash-files +++ b/hash-files @@ -46,16 +46,6 @@ mdls_per_file () { write_per_file () { #echo "=== Write data to a .csv file. === #====================================" - ## Create temp file - temp_csv_file=$($mktemp_bin) - ## Initialize column names - csv_columns=( "File Path" "File Hash" ) - ## Populate Columns from keys of interest - for key in ${keys_of_interest[@]};do - csv_columns+=( ${keys_of_interest[key]} ) - done - ## Print columns to first line of csv - IFS=',';echo "${csv_columns[*]}";IFS=$'\n' # cat $temp_csv_file # write_log "$temp_csv_file written successfully." } @@ -70,11 +60,21 @@ cleanup () { trap cleanup EXIT echo "Main Start" -#echo "=== Get list of files in $Working_Directory. === -#==================================================" +## Create temp file +temp_csv_file=$($mktemp_bin) +## Initialize column names +csv_columns=( "File Path" "File Hash" ) +## Populate Columns from keys of interest +for key in ${keys_of_interest[@]};do + csv_columns+=( ${keys_of_interest[key]} ) +done +## Print columns to first line of csv +IFS=',';echo "${csv_columns[*]}";IFS=$'\n' +## Loop through files, writing to csv for file in $(find $Working_Fullpath -maxdepth 1 -type f); do hash=$($md5_bin $file | awk '{ print $1 }') mdls_properties=$(mdls_per_file $file) + write_per_file $file $hash $mdls_properties done