Datasets:
Download unzipping.sh from OtoroLin/HyperForensics-plus-plus: direct link, hf CLI and curl.
- Browser
- Download file 2.65 kB
-
https://huggingface.co/datasets/OtoroLin/HyperForensics-plus-plus/resolve/main/unzipping.sh
- Command line
-
hf download hf://datasets/OtoroLin/HyperForensics-plus-plus/unzipping.sh
-
curl -L -o unzipping.sh https://huggingface.co/datasets/OtoroLin/HyperForensics-plus-plus/resolve/main/unzipping.sh
2.65 kB
| # Ensure pigz is installed | |
| if ! command -v pigz &> /dev/null; then | |
| echo "Error: pigz is not installed. Please install it and try again." | |
| exit 1 | |
| fi | |
| # Defined the root directory of the whole dataset | |
| ROOT_DIR="../data_test" | |
| # Function to display usage | |
| usage() { | |
| echo "Usage: $0 [--method METHOD --config CONFIG] | [--all]" | |
| exit 1 | |
| } | |
| # Function to unzip a single directory | |
| unzip_config() { | |
| local method=$1 | |
| local config=$2 | |
| local output_path="$ROOT_DIR/$method/$config" | |
| local zipped_file="./data/$method/$config/$config.tar.gz" | |
| echo "Decompressing $zipped_file to $output_path" | |
| # Ensure the output directory exists | |
| mkdir -p "$output_path" | |
| # Create the tar.gz file | |
| echo "Decompressing $zipped_file to $output_path" | |
| tar -xv --use-compress-program=pigz -f "$zipped_file" --directory "$output_path" | |
| if [[ $? -ne 0 ]]; then | |
| echo "Error: Failed to decompress $zipped_file" | |
| exit 1 | |
| fi | |
| # Confirm completion | |
| echo "Decompressing $zipped_file sucessfully to $output_path" | |
| } | |
| # Parse arguments | |
| while [[ "$#" -gt 0 ]]; do | |
| case $1 in | |
| --help) usage ;; | |
| --h) usage ;; | |
| --all) ALL="true" ;; | |
| --method) METHOD="$2"; shift ;; | |
| --config) CONFIG="$2"; shift ;; | |
| *) echo "Unknown parameter: $1"; usage ;; | |
| esac | |
| shift | |
| done | |
| # unzipping all folders | |
| if [[ "$ALL" == "true" ]]; then | |
| # Iterate through all methods and configs | |
| for method_dir in ./data/*; do | |
| if [[ -d "$method_dir" && "$(basename "$method_dir")" != "Origin" ]]; then | |
| method=$(basename "$method_dir") | |
| for config_dir in "$method_dir"/config*; do | |
| if [[ -d "$config_dir" ]]; then | |
| config=$(basename "$config_dir") | |
| unzip_config "$method" "$config" | |
| fi | |
| done | |
| fi | |
| done | |
| if [ -e "./data/Origin/Origin.tar.gz" ]; then | |
| # Ensure the output directory exists | |
| mkdir -p "$ROOT_DIR/Origin" | |
| # decompress tar.gz file | |
| echo "Decompressing ./data/Origin/Origin.tar.gz to $ROOT_DIR/Origin" | |
| tar -xv --use-compress-program=pigz -f "./data/Origin/Origin.tar.gz" --directory "$ROOT_DIR/Origin" | |
| if [[ $? -ne 0 ]]; then | |
| echo "Error: Failed to decompress ./data/Origin/Origin.tar.gz" | |
| exit 1 | |
| fi | |
| fi | |
| echo "All configurations have been zipped successfully." | |
| exit 0 | |
| fi | |
| # Validate arguments | |
| if [[ ! -n "$METHOD" || ! -n "$CONFIG" ]]; then | |
| echo "Error: Both --method and --config or --all must be specified." | |
| usage | |
| fi | |
| unzip_config "$METHOD" "config$CONFIG" |