Skip to content

Instantly share code, notes, and snippets.

@gyakkun
Last active March 7, 2022 01:05
Show Gist options
  • Select an option

  • Save gyakkun/931ab91290fcf58211694b7b9a90d6b3 to your computer and use it in GitHub Desktop.

Select an option

Save gyakkun/931ab91290fcf58211694b7b9a90d6b3 to your computer and use it in GitHub Desktop.

Revisions

  1. gyakkun revised this gist Mar 7, 2022. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions rename_torrent.sh
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,14 @@
    #!/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: ).+$")
    torrent_id=$(echo $i | grep -Po "(?<=\[U2\]\.)\d+")
    new_name="[U2].$torrent_name.$torrent_id.torrent"
    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
    done
  2. gyakkun created this gist Feb 26, 2022.
    12 changes: 12 additions & 0 deletions rename_torrent.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/bin/bash
    PATH='/c/Program Files/Transmission':$PATH
    for i in $(ls \[U2\].*.torrent); do
    torrent_name=$(transmission-show $i | grep -Po "(?<=^Name: ).+$")
    torrent_id=$(echo $i | grep -Po "(?<=\[U2\]\.)\d+")
    new_name="[U2].$torrent_name.$torrent_id.torrent"
    echo "Torrent name: $torrent_name"
    echo "Torrent ID: $torrent_id"
    echo "Original name: $i"
    echo "New name: $new_name"
    mv "$i" "$new_name"
    done