-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aff3e9a
commit 4344b80
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Step 0: Check if 'tourforge.json' exists in the current directory | ||
if [[ ! -f "tourforge.json" ]]; then | ||
echo "'tourforge.json' not found in the current directory!" | ||
exit 1 | ||
fi | ||
|
||
# Step 1: Find all mp3 files without an extension and store their names | ||
mp3_files=() | ||
while IFS= read -r file; do | ||
mp3_files+=("$file") | ||
done < <(find . -type f -exec file --mime-type {} + | grep 'audio/mpeg' | cut -d: -f1) | ||
|
||
# Step 2: Search the 'tourforge.json' file for mp3 filenames and append ".mp3" to them | ||
for mp3 in "${mp3_files[@]}"; do | ||
basename_mp3=$(basename "$mp3") | ||
sed -i "s/\b$basename_mp3\b/$basename_mp3.mp3/g" "tourforge.json" | ||
done | ||
|
||
# Step 3: Rename files to append ".mp3" extension | ||
for mp3 in "${mp3_files[@]}"; do | ||
mv "$mp3" "$mp3.mp3" | ||
done | ||
|
||
echo "Operation completed successfully!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#! /usr/bin/env nix-shell | ||
#! nix-shell -i bash -p imagemagick parallel | ||
|
||
resize_percent=75 # Percentage to resize on each run | ||
max_size=512 # Maximum file size in KB | ||
|
||
# Find all files larger than max_size and check if they are images | ||
files=$(find . -type f -size +${max_size}k | while read -r file; do | ||
if file "$file" | grep -qE 'image|bitmap'; then | ||
echo "$(realpath $file)" | ||
fi | ||
done) | ||
# Process images in parallel | ||
echo "Resizing all of the following image(s) ONCE, please run this script multiple times to bring it below ${max_size}KB" | ||
echo "$files" | ||
echo "$files" | parallel --no-notice magick {} -resize ${resize_percent}% {} |