[dokuwiki] Re: Is there any simple way to cope with files having upper case names?

  • From: Andy Webber <dokuwiki@xxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 21 Aug 2010 09:32:00 +0100

On 20/08/10 19:19, Chris G wrote:
All my digikam photo images have names in upper case, is there any
easy way to copy these to the dokuwiki data/media directory and refer
to them from dokuwiki without changing all their names to lower case?

Changing the names to lower case need not be painful. What's your operating system? If it is Linux then you can easily convert the case of the files using something like this (assuming shell is bash):

$ for i in * ;\
  do \
    j=$(tr [:upper:] [:lower:] <<< "${i}") ;\
    mv --verbose "${i}" "${j}" ;\
  done

If you are going to do this repeatedly on the same directory then you may want to avoid the warnings about files that are already lower-case so you can make the "for" loop only match files that have a leading upper case letter:

$ for i in [[:upper:]]* ;\
  do \
    j=$(tr [:upper:] [:lower:] <<< "${i}") ;\
    mv --verbose "${i}" "${j}" ;\
  done

And anyone that is really keen could also write the "tr" rule to fold characters like space to the wiki-safe alternative of a single "_" - a rough approximation would be:

$ for i in [[:upper:]]* ;\
  do \
j=$(tr [:upper:] [:lower:] <<< "${i}" | tr --squeeze-repeats "[:punct:][:blank:]" "[_*]") ;\
    mv --verbose "${i}" "${j}" ;\
  done


Cheers
Andy
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: