Posts: 14
Joined: Jan 2011
Reputation:
0
Hey shadow! Thanks for jumping in ...
I'm on Mac and know my way around perl / regex scripts :-)
Would like to test your script ... oh and I hate spaces in filenames :-)
Posts: 257
Joined: Jan 2011
Reputation:
5
shadow
Senior Member
Posts: 257
2011-09-11, 18:58
(This post was last modified: 2011-09-11, 19:04 by shadow.)
I just have a couple different for lines for testing how to get the full path and escape characters added, and the echo is to see if the variable is right. Which it isn't for any names with spaces. Unfortunately I got hundreds of movies from a guy that didn't use proper naming and I don't want to fix them.
Running this multiple times just keeps appending the imdb link multiple times and to clean it up after testing just export the library again and overwrite the old ones. Then only run it one time.
#!/bin/bash
export MOVIES=/home/xbmc/movies
cd $MOVIES
for i in `ls -1Rb | sed /^$/d | gawk '/:$/{dir=substr($0,1,length($0)-1)} !/:$/{printf "%s/%s\n",dir,$0}' | grep .nfo`
#for i in `find . -type f | sed 's/[!@\ "()]/\\&/g' | grep .nfo`
do
grep "<id>tt" '$i' | sed s/\ \ \ \ \<id\>tt/http:\\/\\/www.imdb.com\\/title\\/tt/ | sed s/\<\\/id\>// >> '$i'
echo $i
done
edit:
I found the commands used in the for lines on Google and don't understand them.
But I did make the much easier sed lines that actually modify the nfos
Posts: 14
Joined: Jan 2011
Reputation:
0
2011-09-11, 21:46
(This post was last modified: 2011-09-11, 21:55 by Discofris.)
Had to 'macport' gawk first ... :-s
My movies get nicely listed up through the echo command but nfo files aren't modified ... dunnow why.
Will try and understand the commands first :-)
Thanks!
edit: the much easier sed command doesn't also work :-(
Posts: 257
Joined: Jan 2011
Reputation:
5
shadow
Senior Member
Posts: 257
2011-09-12, 02:38
(This post was last modified: 2011-09-12, 05:24 by shadow.)
That is strange the sed commands work great for me maybe test with this one line manually using a test.nfo
grep "<id>tt" test.nfo | sed s/\ \ \ \ \<id\>tt/http:\\/\\/www.imdb.com\\/title\\/tt/ | sed s/\<\\/id\>// >> test.nfo
also try this to see if the url is made fine without modifying the nfo
grep "<id>tt" test.nfo | sed s/\ \ \ \ \<id\>tt/http:\\/\\/www.imdb.com\\/title\\/tt/ | sed s/\<\\/id\>//
*just to be sure you are not on low resolution and ended with extra newlines that should be one line and the for lines should be one each. I thought of that when I viewed the thread on my phone and they wrapped onto 2 lines each.
I don't know if any layout changes have happened to the nfo file since last release to git which I use so make sure when viewing the nfo in a text editor that four spaces exist before the <id> tag if not the script needs changed since I expect them to remove them.
Posts: 257
Joined: Jan 2011
Reputation:
5
shadow
Senior Member
Posts: 257
Try adding this before the for loop. I am on my phone at work so I can't.
IFS=$'\n'