Adaptable cloning script

Adaptable cloning script

by Emma Richardson -
Number of replies: 1
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

I have a client that needed multiple clones of the Adaptable theme.  After manually making several, I decided to come up with a script that would do the theme cloning. 

I am sharing it here in case it helps someone else.  I was running it on a mac - it needs to be run from the folder containing the adaptable folder.

Just copy the text below to a bash script.

cp -R adaptable newtheme
cd newtheme
find . -name '*.js' -print0 | xargs -0 sed -i "" "s/adaptable/newtheme/g"
find . -name '*.txt' -print0 | xargs -0 sed -i "" "s/adaptable/newtheme/g"
find . -name '*.php' -print0 | xargs -0 sed -i  "" "s/adaptable/newtheme/g"
find . -name '*.css' -print0 | xargs -0 sed -i "" "s/adaptable/newtheme/g"
find . -name '*.mustache' -print0 | xargs -0 sed -i "" "s/adaptable/newtheme/g"
find . -name '*.js' -print0 | xargs -0 sed -i "" "s/Adaptable/NewTheme/g"
find . -name '*.txt'-print0 | xargs -0 sed -i "" "s/Adaptable/NewTheme/g"
find . -name '*.php' -print0 | xargs -0 sed -i "" "s/Adaptable/NewTheme/g"
find . -name '*.css' -print0 | xargs -0 sed -i "" "s/Adaptable/NewTheme/g"
find . -name '*.mustache' -print0 | xargs -0 sed -i "" "s/Adaptable/NewTheme/g"

mv settings/adaptable_admin_setting_getprops.php settings/newtheme_admin_setting_getprops.php
mv settings/adaptable_admin_setting_putprops.php settings/newtheme_admin_setting_putprops.php
mv jquery/adaptable_v2_1_1_2.js jquery/newtheme_v2_1_1_2.js
mv tests/adaptabletoolbox_test.php tests/newthemetoolbox_test.php
mv style/adaptable.css style/newtheme.css
mv amd/build/adaptable.min.js amd/build/newtheme.min.js
mv amd/src/adaptable.js amd/src/newtheme.js
mv lang/en/theme_adaptable.php lang/en/theme_newtheme.php

Saved me countless hours - hope it helps someone else.

Average of ratings: Useful (2)
In reply to Emma Richardson

Re: Adaptable cloning script

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Interesting Emma,

I've not done shell scripts in ages, can they take a parameter for the 'newtheme' name?

Or could be written in C with forking of the process and using argv / argc ?