: ) wonderful world ( :

the metasyntactic variable

Archive for May 2008

file renamer improvement

without comments

I decided to create a context menu for files to remove spaces or unwanted characters from the name. I use nautilus, you are able to do so by nautilus-actions package. We need the script which will run in case the menupoint is selected. If multiple files are selected, a space separated list of them will be the parameter. My script is like this

#!/usr/bin/zsh

pattern="[^a-zA-Z0-9-.]"
for (( i=1 ; i<=$# ; i+=1 ))
do
  source=$*[$i]
  target=${source:h}/${${source:t}//${~pattern}/_}
  if [[ ! -a $target ]] then
    mv "$source" "$target"
  fi
done

Written by grault

May 18, 2008 - 9:14 pm at May 18, 2008 - 9:14 pm

Posted in linux

this week’s tobacco

without comments

Lucky Strike White Portion. Nothing special. Nice metal can though.

Written by grault

May 14, 2008 - 8:08 pm at May 14, 2008 - 8:08 pm

Posted in snus, tobacco

file renamer

with 2 comments

Let’s suppose you have a bunch of files with various characters in filename which you want to get rid of. I mean you want to eliminate those characters, not the files.

afroid-laptop% paste <(ls -1 | sed -e 's/^\(.*\)$/"\1"/') <(ls -1 | sed -e 's/\ /
_/g') | sed -e 's/^/mv /'
mv "01 Track 01 13.mp3" 01_Track_01_13.mp3
mv "02 Track 02 22.mp3" 02_Track_02_22.mp3
mv "03 Track 03 32.mp3" 03_Track_03_32.mp3
mv "04 Track 04 42.mp3" 04_Track_04_42.mp3
mv "05 Track 05 52.mp3" 05_Track_05_52.mp3
mv "06 Track 06 62.mp3" 06_Track_06_62.mp3
mv "07 Track 07 72.mp3" 07_Track_07_72.mp3
mv "08 Track 08 82.mp3" 08_Track_08_82.mp3
mv "09 Track 09 91.mp3" 09_Track_09_91.mp3
afroid-laptop% paste <(ls -1 | sed -e 's/^\(.*\)$/"\1"/') <(ls -1 | sed -e 's/\ /
_/g') | sed -e 's/^/mv /' | sh
afroid-laptop% ls
01_Track_01_13.mp3  04_Track_04_42.mp3  07_Track_07_72.mp3
02_Track_02_22.mp3  05_Track_05_52.mp3  08_Track_08_82.mp3
03_Track_03_32.mp3  06_Track_06_62.mp3  09_Track_09_91.mp3
afroid-laptop%

Written by grault

May 14, 2008 - 8:03 pm at May 14, 2008 - 8:03 pm

Posted in command line, linux

down the road

without comments

Taboca had a little bit dodgy can, good taste though.

Gotland Gul was very rustic and has potty taste.

Mocca Pomegranate White Mini Portion was very tasty but mini so no power at all. Was the best out of this three though.

Written by grault

May 8, 2008 - 7:56 pm at May 8, 2008 - 7:56 pm

Posted in snus, tobacco