Using the Windows Command Line to Automate Edits
Posted on March 3, 2014 in Command Line, Windows by Matt Jennings
Note: These commands use Command Prompt, the default shell on Windows. I use them all the time to do small website edits at my job.
Steps to Automate Small Edits on Websites
- Download Notepad++, an excellent free text editor to complete this tutorial.
- Download the
updates.zip
directory that contains files you’ll need here and move it to yourDesktop
. - After unzipping the
updates.zip
directory that you downloaded, you’ll see additional files inside as shown below:---updates ------aaa-working ------backup ------resources ------www ------zzz01_bckup_to_wking.bat ------zzz01_wking_to_www.bat ------zzzz_____spacer03.bat ------zzzz_____spacer04.bat ------ZZZZZZ__DESTOYER.bat
- Inside the
updates
directory, right-clickzzz01_bckup_to_wking.bat
and left-clickEdit with Notepad++
from the menu that appears so you can edit the file. - Inside
zzz01_bckup_to_wking.bat
replaceusername
with your Windows username. If you’re on a work computer and your name is Jane Doe it’ll be something likejdoe
. - Follow the same process to change the username text in all the other
.bat
files EXCEPT forzzzz_____spacer03.bat
andzzzz_____spacer03.bat
. - Put a file in the
resources
directory that you wouldn’t upload to a website, like a Photoshop PSD. Or, anything else will do. - Download a file from a website you’re going to edit, like
contact.php
, into thebackup
directory. - Double-click
zzz01_bckup_to_wking.bat
to copycontact.php
from thebackup
directory to theaaa-working
directory. - Open
contact.php
in theaaa-working
directory, edit it, save it and close it. - Click the
zzz02_wking_to_www.bat
file to copycontact.php
from theaaa-working
directory to thewww
directory. - Zip the
backup
,resources
, andwww
directories. You will now see the new zipped files below inside yourupdates
directory:---updates ------aaa-working ------backup ------resources ------www ------backup.zip ------resources.zip ------www.zip ------zzz01_bckup_to_wking.bat ------zzz01_wking_to_www.bat ------zzzz_____spacer03.bat ------zzzz_____spacer04.bat ------ZZZZZZ__DESTOYER.bat
- Upload
contact.php
which has been edited from yourwww
directory to the live website to make the changes live. - Upload the
aaa-working.zip
,resources.zip
andwww.zip
zipped files into your remote backup server. - Double-click the
ZZZZZZ__DESTOYER.bat
file to delete all the ZIP files and directories and then recreate the directories. These files should go to your recycle bin and you can start a new edit. - I created the
zzzz_____spacer03.bat
andzzzz_____spacer04.bat
files to prevent you from accidentally moving your mouse too far below thezzz02_wking_to_www.bat
file and clicking on theZZZZZZ__DESTOYER.bat
file which would delete all your work! Clicking thespacer
files do nothing.