Skip to content

Instantly share code, notes, and snippets.

@luckylittle
Last active June 28, 2019 11:39
Show Gist options
  • Save luckylittle/709d0f3c526ba9bcde345866acd9fcae to your computer and use it in GitHub Desktop.
Save luckylittle/709d0f3c526ba9bcde345866acd9fcae to your computer and use it in GitHub Desktop.
Add / Remove extension to multiple files in Linux
#!/bin/bash
# ls -1
# Dark.Money.2018.DVDRip.x264-WiDE
# Golden.State.Killer.Main.Suspect.2018.INTERNAL.WEB.x264-UNDERBELLY
# Shazam.2019.BDRip.x264-SPARKS
# The.Best.of.Enemies.2019.BDRip.x264-DRONES
# The.Kindergarten.Teacher.2018.BDRip.X264-AMIABLE
# ADD EXTENSION:
for x in *; do mv -v ${x}{,.torrent}; done
#‘Dark.Money.2018.DVDRip.x264-WiDE’ -> ‘Dark.Money.2018.DVDRip.x264-WiDE.torrent’
#‘Golden.State.Killer.Main.Suspect.2018.INTERNAL.WEB.x264-UNDERBELLY’ -> ‘Golden.State.Killer.Main.Suspect.2018.INTERNAL.WEB.x264-UNDERBELLY.torrent’
#‘Shazam.2019.BDRip.x264-SPARKS’ -> ‘Shazam.2019.BDRip.x264-SPARKS.torrent’
#‘The.Best.of.Enemies.2019.BDRip.x264-DRONES’ -> ‘The.Best.of.Enemies.2019.BDRip.x264-DRONES.torrent’
#‘The.Kindergarten.Teacher.2018.BDRip.X264-AMIABLE’ -> ‘The.Kindergarten.Teacher.2018.BDRip.X264-AMIABLE.torrent’
# REMOVE EXTENSION:
rename -v .torrent '' *.torrent
#`Dark.Money.2018.DVDRip.x264-WiDE.torrent' -> `Dark.Money.2018.DVDRip.x264-WiDE'
#`Golden.State.Killer.Main.Suspect.2018.INTERNAL.WEB.x264-UNDERBELLY.torrent' -> `Golden.State.Killer.Main.Suspect.2018.INTERNAL.WEB.x264-UNDERBELLY'
#`Shazam.2019.BDRip.x264-SPARKS.torrent' -> `Shazam.2019.BDRip.x264-SPARKS'
#`The.Best.of.Enemies.2019.BDRip.x264-DRONES.torrent' -> `The.Best.of.Enemies.2019.BDRip.x264-DRONES'
#`The.Kindergarten.Teacher.2018.BDRip.X264-AMIABLE.torrent' -> `The.Kindergarten.Teacher.2018.BDRip.X264-AMIABLE'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment