Archive for October, 2015

sed: batch file rename

Friday, October 16th, 2015

Deleting plus sign from multiple filenames.

Is:

-rw-r--r--. 1 root root  153771 Oct 16 10:11 node-01-1444744974.2017874_in_+38050190.ogg
-rw-r--r--. 1 root root  167217 Oct 16 10:11 node-03-1444736219.1609540_in_+38050190.ogg
-rw-r--r--. 1 root root  141165 Oct 16 10:11 node-07-1444726601.1585794_in_+38073454.ogg
-rw-r--r--. 1 root root  193136 Oct 16 10:11 node-27-1444726479.1648259_in_+38073454.ogg

Must be:

-rw-r--r--. 1 root root  153771 Oct 16 09:58 node-01-1444744974.2017874_in_38050190.ogg
-rw-r--r--. 1 root root  167217 Oct 16 09:58 node-03-1444736219.1609540_in_38050190.ogg
-rw-r--r--. 1 root root  141165 Oct 16 09:56 node-07-1444726601.1585794_in_38073454.ogg
-rw-r--r--. 1 root root  193136 Oct 16 09:57 node-27-1444726479.1648259_in_38073454.ogg

Script:

#!/bin/bash

for i in *ogg
do
	mv "$i" "`echo $i | sed 's/\+//'`"
done