Created
June 10, 2017 23:19
-
-
Save jcanfield/cda8ab8027ec32e5273af0d685add5d8 to your computer and use it in GitHub Desktop.
Use bash and linux tools to rename files in a folder, to the folder name.
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 | |
# SYNOPSIS: Rename all files in folder to match folder name. | |
# Testing 1 | |
# rename -vn 's:(/[^/]*)/[^/]*$:$1$1.mkv:' folder/*/*.mkv | |
# Testing 2 | |
#for f in folder/*/*.mkv;do dn="${f%/*}";echo mv -v "$f" "${dn}/${dn##*/}.mkv";done | |
# Testing #3 | |
# find folder/* -maxdepth 0 -type d -execdir sh -c 'test -f "$0"/*.mkv"&&echo mv -v "$0"/*.mkv "$0/${0##*/}.iso"' '{}' \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment