Get just the file title without the extension in a variable.
file_name=1
file_title=`echo1|sed 's/\..\{3\}$//'`
Byte sized tech know-how.
Get just the file title without the extension in a variable.
file_name=1
file_title=`echo1|sed 's/\..\{3\}$//'`
Copyright © 2024 Txt
This doesn’t work
Worked great for me. Thanks for posting this. Just for info, I used it help convert a bunch of pictures with the following one liner:-
for f in *.JPG;do g=`echo f|sed ‘s/\..\{3\}//’`;convert -resize 800×600 f thumbs/g.eps ;done
@stuphi
Take a look at http://txt.binnyva.com/2008/11/shell-script-for-batch-convertion-of-images/
That’s my method
This is nice b/c unlike a lot of solutions, if there exists a ‘.’ somewhere in the filename, e.g. “ILikeToSeparateDates_w-periods(2011.02.20).mp4” it does not remove the date.
Samuel, try this:
$ echo “ILikeToSeparateDates_w-periods(2011.02.20).mp4” | sed ‘s/\(.*\)…./\1/’
ILikeToSeparateDates_w-periods(2011.02.20)
I’d use something like:
FULL=`echo 1`
EDIT=s:\\.`echo{FULL} | sed ‘s:.*\.::’`::g
CLIP=`echo {FULL} | sed -e{EDIT}`
echo ${FULL}
This works fine on
“ILikeToSeparateDates_w-periods(2011.02.20).mp4”
and even on
“IncludedExtensionInName(good mp4 of 2011.02.20).mp4”
but slightly mangles
RecussiveName(badName.mp4 of 2011.02.20).mp4
into
RecussiveName(badName of 2011.02.20)
line 4 of above should be
echo {CLIP}
and not
echo{FULL}