User:Simpsons Dumper/handy commands

From The VG Resource Wiki
Jump to: navigation, search

A copy of my "handy commands" text file. For use with the Linux terminal, complete with example names from whatever I was working on when I added these to my file.

bulk remove from name:
rename 's/data_00//g' *

name to sequential numbers:
ls | cat -n | while read n f; do mv "$f" `printf "%03d.wav" $n`; done

rename with extras:
for f in *; do mv -- "$f" "PRE_$f_SUF"; done

rename non-zero-padded to zero-padded:
for f in *; do mv "$f" "`printf %03.f ${f//[!0-9]/}`".wav; done

name directories to sequential numbers:

for d in voicetest/*/
     (cd "$d" && ls | cat -n | while read n f; do mv "$f" `printf "%03d.wav" $n`; done)

cleanup files in directories:
rm */*.bcwav

delete duplicates:
fdupes -rdN .

list duplicates:
fdupes -r .

zip with directory:
zip -r Simpsons\ Skateboarding/Willie/

zip with directories:

for d in The\ Simpsons\ Game/Voice/*/
	IFS='/'; arr=($d); unset IFS;
	zip -r "${arr[2]}.zip" "$d"

convert all audio in directory:
find -name "*.sndS" -exec bash -c 'sox -t raw -r 22050 -b 8 -c 1 -L -e unsigned-integer "{}" "${0/.sndS}.wav" trim 0.0004' {} \;

ffmpeg -i MAHB.MNG -vf "scale='min(2048,iw)':min'(2048,ih)':force_original_aspect_ratio=decrease,pad=2048:2048:(ow-iw)/2:(oh-ih)/2:gray" out/%d.png
for f in out/* ; do convert "$f" -trim +repage "$f" ; done

big bulk:
echo *.rgb | xargs -n 100 wine tstoimg.exe --rgb2png