Created
April 14, 2013 11:16
-
-
Save archfizz/5382336 to your computer and use it in GitHub Desktop.
Remove file extension from one file or from all files in working directory
This file contains 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
## To remove a file extension from a given file | |
## Load the following function | |
rmext () { | |
if test -f "$1" | |
then | |
F=$1 | |
E=${F#*.} | |
mv $1 `basename $1 .$E`; | |
fi | |
} | |
# Then use based on these given examples | |
# | |
# rmext mixset.mp3 | |
# rmext lastnightsparty.jpg | |
# ------------------------- | |
## To Remove a file extension from all files in the current working directory | |
## Load the following function | |
rmextdir () { | |
for i in * | |
do | |
if test -f "$i" | |
then | |
mv $i `basename $i .$1`; | |
fi | |
done | |
} | |
# Then use based on these given examples | |
# | |
# rmextdir mp3 | |
# rmextdir jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment