deepfaketar / bash /copyimages.sh
blorg469's picture
Upload folder using huggingface_hub
90cd92a verified
#!/bin/bash
# Usage: ./copy_images.sh source.jsonl /path/to/destination/folder
# Check for required arguments
if [ "$#" -ne 2 ]; then
echo "Usage: $0 source.jsonl /path/to/destination/folder"
exit 1
fi
# Input JSONL file and destination folder
INPUT_JSONL=$1
DEST_FOLDER=$2
# Check if jq is installed
if ! command -v jq &> /dev/null; then
echo "jq is not installed. Please install jq to proceed."
exit 1
fi
# Ensure the destination folder exists
mkdir -p "$DEST_FOLDER"
# Process the JSONL file and copy each image using scp
while IFS= read -r line; do
# Extract the image path using jq for each line
image_path=$(echo "$line" | jq -r '.image // empty')
# Check if image_path is not empty
if [ -n "$image_path" ]; then
# Extract the filename from the image path
filename=$(basename "$image_path")
# Perform the scp command (use `cp` for local copy, replace with `scp` for remote)
scp "$image_path" "$DEST_FOLDER/$filename"
else
echo "No image path found in: $line"
fi
done < "$INPUT_JSONL"
echo "All images have been copied to $DEST_FOLDER."