every once and a while you would like to save some disk space… by re-encoding your *.jpg and *.mp4 from your mobile phone…

you can do this with this pretty nice windows program (shiiit) http://www.any-video-converter.com/products/for_video_free/

linux alternatives: https://askubuntu.com/questions/264215/which-is-best-audio-video-converter-on-linux

anyway it’s about mass-renaming: WARNING! THIS WORKS DAMN FAST 😀

apt-get update;
apt-get install ksh; # install KornShell

# i have a bunch of files
-rw-r--r-- 1 user user 451M Apr 23 04:04 VID_20170115_111358_x264.mp4
-rw-r--r-- 1 user user 8.4M Apr 23 04:05 VID_20170213_172301_x264.mp4
-rw-r--r-- 1 user user  66M Apr 23 04:12 VID_20170220_145626_x264.mp4
...
# i would like to have them renamed to:

VID_20170115_111358.mp4 # <- original filename without the _x264

ls | awk -F. '{printf "mv %s %s.%s\n",$0,substr($1,1,length($1)-5),$2 ;}'; # preview
mv VID_20160725_182919_x264.mp4 VID_20160725_182919.mp4; # looks good

# what you will need to modify if you need to remove more or less chars before the dot .
# is the number 5 here

# 5 = would remove = _x264
# 6 = would remove = 4_x264
# 7 = would remove = 14_x264

ls | awk -F. '{printf "mv %s %s.%s\n",$0,substr($1,1,length($1)-5),$2 ;}' | ksh; # do the job

# works pretty damn fast :)

what is ksh?

manpage KornShell: ksh.man.txt

admin