Skip to content
Snippets Groups Projects
Commit 35006bae authored by am0ebe's avatar am0ebe
Browse files

add cpsizejpegs.sh script to cp size jpegs to test folder

parent e036706e
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# Step 1: List JPEG files sorted by name (timestamp)
files=$(ls *.jpg | sort)
# Step 2: Calculate the cumulative size and select files until 1GB is reached
size=0
limit=$((1024 * 1024 * 1024)) # 1GB in bytes
selected_files=""
for file in $files; do
filesize=$(stat -c%s "$file") # Get file size in bytes
new_size=$((size + filesize))
if [ "$new_size" -le "$limit" ]; then
size=$new_size
selected_files="$selected_files $file"
else
break
fi
done
# Step 3: Copy or move the selected files
cp $selected_files ./test
# mv $selected_files /path/to/destination/ # Uncomment to move files instead
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment