Skip to content

Instantly share code, notes, and snippets.

@mmstick
Last active August 29, 2015 14:06
Show Gist options
  • Save mmstick/040aeacea375fb070fc4 to your computer and use it in GitHub Desktop.
Save mmstick/040aeacea375fb070fc4 to your computer and use it in GitHub Desktop.
This is a fish function -- store it inside ~/.config/fish/functions to use with fish. Renames all episodes in a directory to the TVDB naming-scheme and verbosely prints the changes. Ex: Series 1x01.mkv
#!/bin/fish
function rename-series --description 'rename-series <series_name> <season_number> <file_extension>'
set count 0
for file in *
set count (math $count + 1)
if test (math $count \< 10) = '1'
mv -i -v "$file" "$argv[1] $argv[2]x0$count.$argv[3]"
else
mv -i -v "$file" "$argv[1] $argv[2]x$count.$argv[3]"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment