Re: [arch-general] a bit more script
On Tue, 20 Mar 2012 14:52:34 + John K Pate 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
Re: [arch-general] a bit more script
On Tue, 20 Mar 2012 17:00:43 +0200 Jesse Juhani Jaara wrote: > ti, 2012-03-20 kello 14:37 +, 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 " onclick=\"return hs.expand(this)\">" \; > >> 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
Re: [arch-general] a bit more script
ti, 2012-03-20 kello 14:37 +, 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 "" \; >> awardgallery.html seens i did a small mistake while copying yout html signature.asc Description: This is a digitally signed message part
Re: [arch-general] a bit more script
> 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.
Re: [arch-general] a bit more script
On Tue, 20 Mar 2012 10:24:08 +0200 Jesse Juhani Jaara 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 " onclick=\"return hs.expand(this)\">" ; > 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
Re: [arch-general] a bit more script
On Tue, 2012-03-20 at 08:15 +, 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 " onclick=\"return hs.expand(this)\">" ; > done > awardgallery.html > > which works well and generates > > > > The slight problem is in this part > 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.
Re: [arch-general] a bit more script
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 "" ; done >> awardgallery.html signature.asc Description: This is a digitally signed message part
Re: [arch-general] a bit more script
ti, 2012-03-20 kello 08:15 +, pete kirjoitti: > The slight problem is in this part > 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 "" \; >> gallery.html the \ before ; is importand there :D \; signature.asc Description: This is a digitally signed message part