Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate .csv formatted basic metadata, fast to obtain, but allowing heuristics for syncing files or initial eastimation of backup/sync coverage. ( And yes, I know that this find command will not properly encode filenames containing quotes according to csv standard )
#!/bin/bash
# Generate .csv formatted basic metadata, fast to obtain, but allowing heuristics for syncing files or initial eastimation of backup/sync coverage.
fullpath="${1:-$PWD}"
dest="${2:-"$fullpath"/basic_files_metadata.csv.gz}"
hostname="${3:-"$(hostname)"}"
echo "find \"${fullpath}\" -type f -exec stat --format=\"%i,%Y,%s,%m,%n\" \"{}\" \\; > \"${dest}\""
echo "Progress in lines generated:"
(echo "inode,modification_ts,size,hostname,mount,path";
find "${fullpath}" -type f -exec stat --format="%i,%Y,%s,${hostname},%m,%n" "{}" \;
) | pv -l | gzip > "${dest}"
echo -n Finished:
ls -lha "${dest}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment