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