well, I got a set of folders each containing a *.nfo file from XBMC (beside other files such as videos and pictures etc).
I want to rename the folder by strings inside the *.nfo file. The relevant content of such a *.nfo file:
...
<title>Filmtitle</title>
...
<year>2011</year>
...
<director>Werner Herzog</director>
...
UPDATE: here is an unmodified, original .nfo file from XBMC
I tried a lot with find exec
and grep
, but I did not really get anythin usable...
In the example above the folder should have the name "Filmtitel [2011, Werner Herzog]"
Maybe someone can help me out!
Try the following script. It extracts the title, year and director from each file and then renames the directory:
(Simply uncomment the
mv
command if you are happy that the commands being printed out are correct.)