Last active
March 7, 2022 01:05
-
-
Save gyakkun/931ab91290fcf58211694b7b9a90d6b3 to your computer and use it in GitHub Desktop.
Rename U2 torrent in Git Bash (Windows)
This file contains hidden or 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
| #!/bin/bash | |
| OLDIFS="$IFS" | |
| IFS=$'\n' | |
| PATH='/c/Program Files/Transmission':$PATH | |
| for i in $(ls \[U2\].*.torrent); do | |
| torrent_name=$(transmission-show $i | grep -Po "(?<=^Name: ).+$") | |
| echo "Torrent name: $torrent_name" | |
| torrent_id=$(echo $i | grep -Po "(?<=\.)\d+(?=\.torrent)") | |
| echo "Torrent ID: $torrent_id" | |
| new_name="[U2].$torrent_name.$torrent_id.torrent" | |
| echo "Original name: $i" | |
| echo "New name: $new_name" | |
| mv "$i" "$new_name" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment