Skip to content

Posts from the ‘Code’ Category


Batch file and directory rename

I needed a quick way to go through a directory and rename some files and directories to remove a specific bit from the name. By using bash’s parameter expansion feature we can accomplish that in just a few lines.

for i in *something* ; do
echo ${i/-*[something]}
mv $i ${i/-*[something]}

This takes all files and directories with something somewhere in their name, and strips it out.