LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-08-2011, 12:00 AM   #1
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Slackware and Fedora
Posts: 234

Rep: Reputation: 2
I have a specific linux bash question about variables and possible hexadecimals.


So I have season one of bleach and it is separated into 5 disks. I have xbmc and I wanted to take a library and add all of my episode from one directory into one file called videodb.xml Which is with in xbmc_videodb_2011-10-08 which is within my bleach folder in my home folder. I found the file names requires different id's for each video I have. Before we go any farther I encoded them into the avi format which I researched to be compliant with the xbox 360.

I put some notes in the shell script.

Code:
#!/bin/bash

echo "<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>" >> xbmc_videodb_2011-10-08/videodb.xml
echo "<videodb>" >> xbmc_videodb_2011-10-08/videodb.xml

a=xx00000000 # This is the starting address
for i in ./*
{
    a++ # I don't know how to make this count up from the starting
######### address so that it does this xx00000000 to xx0000001 and
######### so on.
    echo "    <movie>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <title>$i</title>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <rating>0.000000</rating>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <epbookmark>0.000000</epbookmark>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <year>0</year>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <top250>0</top250>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <votes></votes>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <outline></outline>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <plot></plot>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <tagline></tagline>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <runtime></runtime>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <mpaa></mpaa>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <playcount>0</playcount>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <lastplayed></lastplayed>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <file></file>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <path>/home/branden/Bleach.Episodes.1-222.Movie.1-2.plus.OVA.japdub.engsub/</path>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <filenameandpath>/home/branden/Bleach.Episodes.1-222.Movie.1-2.plus.OVA.japdub.engsub/$i</filenameandpath>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <id>$a</id>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <genre>Anime</genre>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <premiered></premiered>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <status></status>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <code></code>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <aired></aired>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "        <trailer></trailer>" >> xbmc_videodb_2011-10-08/videodb.xml
    echo "    </movie>" >> xbmc_videodb_2011-10-08/videodb.xml
}

echo "    <paths />" >> xbmc_videodb_2011-10-08/videodb.xml
echo "</videodb>" >> xbmc_videodb_2011-10-08/videodb.xml
 
Old 10-08-2011, 08:01 AM   #2
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 360

Rep: Reputation: 170Reputation: 170
This counts up in hexadecimal.
Code:
a=xx00000000
for i in ./*; do
  atmp=${a/x/0}  # Change first 'x' to '0'
  a=$(printf 'xx%08X' $((++atmp)) )
#        use 'xx%08x' for lower case A-F
  echo $a
done

xx00000001
xx00000002
xx00000003
xx00000004
xx00000005
xx00000006
xx00000007
xx00000008
xx00000009
xx0000000A
xx0000000B
xx0000000C
xx0000000D
xx0000000E
xx0000000F
xx00000010
 
Old 11-13-2011, 01:14 AM   #3
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Slackware and Fedora
Posts: 234

Original Poster
Rep: Reputation: 2
I did not respond for a while, but yes it worked.
 
Old 11-13-2011, 03:20 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
May I also suggest you look up here documents instead of so many echo lines.
 
  


Reply

Tags
bash, multimedia, scripting, syntax, xbmc



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash question about variables CrossoverPsycho Programming 6 01-30-2010 08:11 AM
Question about variables in BASH scripts gimpy530 Linux - General 5 11-19-2009 10:02 PM
bash/ksh variables question tpe Programming 2 08-11-2005 09:39 AM
BASH variables evaluation question. Thetargos Programming 11 08-11-2003 04:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration