Hi folks . Sorry to be a pain but i am still having a bit of fun (or not as the case may be) with scripting here thanks to previous help i have for f in *jpg ; do echo "<a class=\"highslide\" href=\"$f\" onclick=\"return hs.expand(this)\"><img src=\"thumbs/\"$f\"></a>" ; done > awardgallery.html which works well and generates <a class="highslide" href="img_0004.jpg" onclick="return hs.expand(this)"><img src="thumbs/"img_0004.jpg"></a> The slight problem is in this part <img src="thumbs/"img_0004.jpg"> thumbs is a sub dir off the main photos with thumbnails in it they are named img_0004_s.jpg and i can get it to pick this fact up that means i have an edit job every time . help with mods please folks Thanks pete . -- Linux 7-of-9 3.2.11-1-ARCH #1 SMP PREEMPT Thu Mar 15 09:19:02 CET 2012 x86_64 AMD Phenom(tm) 9600B Quad-Core Processor AuthenticAMD GNU/Linux
ti, 2012-03-20 kello 08:15 +0000, pete kirjoitti:
The slight problem is in this part <img src="thumbs/"img_0004.jpg"> thumbs is a sub dir off the main photos with thumbnails in it they are named img_0004_s.jpg and i can get it to pick this fact up that means i have an edit job every time . help with mods please folks
You can use find comman in these cases :D find /image/dir -name '*.jpg' -exec echo "<a class...>" \; >> gallery.html the \ before ; is importand there :D \;
Oh sorry I forgot something important from the command. In for f in... you use $f to replace the filename. In find you -exec you use {} find . -name '*.jpg' -exec echo "<a class=\"highslide\" href=\"{}\" onclick=\"return hs.expand(this)\"><img src=\"thumbs/\"{}\"></a>" ; done >> awardgallery.html
On Tue, 20 Mar 2012 10:24:08 +0200 Jesse Juhani Jaara <jesse.jaara@gmail.com> wrote:
Oh sorry I forgot something important from the command. In for f in... you use $f to replace the filename. In find you -exec you use {} find . -name '*.jpg' -exec echo "<a class=\"highslide\" href=\"{}\" onclick=\"return hs.expand(this)\"><img src=\"thumbs/\"{}\"></a>" ; done >> awardgallery.html
Hi Well sorry but that does nothing but generate a blank awardgallery.html and a complaint of line 2: syntax error near unexpected token `done' so guess it's back to hacking by hand Thanks to John K Pate but i dont at the moment have time to sit and digest heaps of variables i just need to solve this one problem . I can study when i have more time and found somewhere else to live outside of bloody Sandwell .. Thanks Pete . -- Linux 7-of-9 3.2.11-1-ARCH #1 SMP PREEMPT Thu Mar 15 09:19:02 CET 2012 x86_64 AMD Phenom(tm) 9600B Quad-Core Processor AuthenticAMD GNU/Linux
Thanks to John K Pate but i dont at the moment have time to sit and digest heaps of variables i just need to solve this one problem .
You want to be able to change "img_0004.jpg" to "img_0004_s.jpg", right? You can use the built-in string replace functionality of bash to achieve this (described in the first hit of that google search): $ f=img_0004.jpg $ echo $f img_0004.jpg $ echo ${f/.jpg/_s.jpg} img_0004_s.jpg == John K Pate http://homepages.inf.ed.ac.uk/s0930006/ -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.
On Tue, 20 Mar 2012 14:52:34 +0000 John K Pate <j.k.pate@sms.ed.ac.uk> wrote:
Thanks to John K Pate but i dont at the moment have time to sit and digest heaps of variables i just need to solve this one problem .
You want to be able to change "img_0004.jpg" to "img_0004_s.jpg", right? You can use the built-in string replace functionality of bash to achieve this (described in the first hit of that google search):
$ f=img_0004.jpg $ echo $f img_0004.jpg $ echo ${f/.jpg/_s.jpg} img_0004_s.jpg
== John K Pate http://homepages.inf.ed.ac.uk/s0930006/
Hi John .. well sort of yes what it is the structure of the gallery is the main pictures in a dir then in a sub dir are the thumbnails which are named such as img0005-s.jpg for the thumbnails and img0005.jpg for the main pictures , it would make life a lot easier if the script was able to setup the main and the thumbs correctly what happens right now is it sets both to the main image name meaning i have to go in and edit up to 500 lines PITA there is enough variance to make the automatic find and replace fail .. Pete . -- Linux 7-of-9 3.2.11-1-ARCH #1 SMP PREEMPT Thu Mar 15 09:19:02 CET 2012 x86_64 AMD Phenom(tm) 9600B Quad-Core Processor AuthenticAMD GNU/Linux
ti, 2012-03-20 kello 14:37 +0000, pete kirjoitti:
Well sorry but that does nothing but generate a blank awardgallery.html and a complaint of line 2: syntax error near unexpected token `done'
find . -name '*.jpg' -exec echo "<a class=\"highslide\" href=\"{}\" onclick=\"return hs.expand(this)\"><img src=\"thumbs/\"{}\"></a>" \; >> awardgallery.html seens i did a small mistake while copying yout html
On Tue, 20 Mar 2012 17:00:43 +0200 Jesse Juhani Jaara <jesse.jaara@gmail.com> wrote:
ti, 2012-03-20 kello 14:37 +0000, pete kirjoitti:
Well sorry but that does nothing but generate a blank awardgallery.html and a complaint of line 2: syntax error near unexpected token `done'
find . -name '*.jpg' -exec echo "<a class=\"highslide\" href=\"{}\" onclick=\"return hs.expand(this)\"><img src=\"thumbs/\"{}\"></a>" \;
awardgallery.html
seens i did a small mistake while copying yout html
Hi .. Ok well i have had to do it by hand for now once i get sorted later in the year i will have to sit down and do some heavy duty reading on bash and friends .. Thanks Pete . -- Linux 7-of-9 3.2.11-1-ARCH #1 SMP PREEMPT Thu Mar 15 09:19:02 CET 2012 x86_64 AMD Phenom(tm) 9600B Quad-Core Processor AuthenticAMD GNU/Linux
On Tue, 2012-03-20 at 08:15 +0000, pete wrote:
Hi folks .
Sorry to be a pain but i am still having a bit of fun (or not as the case may be) with scripting here
thanks to previous help i have
for f in *jpg ; do echo "<a class=\"highslide\" href=\"$f\" onclick=\"return hs.expand(this)\"><img src=\"thumbs/\"$f\"></a>" ; done > awardgallery.html
which works well and generates
<a class="highslide" href="img_0004.jpg" onclick="return hs.expand(this)"><img src="thumbs/"img_0004.jpg"></a>
The slight problem is in this part <img src="thumbs/"img_0004.jpg"> thumbs is a sub dir off the main photos with thumbnails in it they are named img_0004_s.jpg and i can get it to pick this fact up that means i have an edit job every time . help with mods please folks
https://www.google.com/search?q=string+handling+bash == John K Pate http://homepages.inf.ed.ac.uk/s0930006/ -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.
participants (3)
-
Jesse Juhani Jaara
-
John K Pate
-
pete