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.zipdirectory that contains files you’ll need here and move it to yourDesktop. - After unzipping the
updates.zipdirectory 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
updatesdirectory, right-clickzzz01_bckup_to_wking.batand left-clickEdit with Notepad++from the menu that appears so you can edit the file. - Inside
zzz01_bckup_to_wking.batreplaceusernamewith 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
.batfiles EXCEPT forzzzz_____spacer03.batandzzzz_____spacer03.bat. - Put a file in the
resourcesdirectory 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 thebackupdirectory. - Double-click
zzz01_bckup_to_wking.batto copycontact.phpfrom thebackupdirectory to theaaa-workingdirectory. - Open
contact.phpin theaaa-workingdirectory, edit it, save it and close it. - Click the
zzz02_wking_to_www.batfile to copycontact.phpfrom theaaa-workingdirectory to thewwwdirectory. - Zip the
backup,resources, andwwwdirectories. You will now see the new zipped files below inside yourupdatesdirectory:---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.phpwhich has been edited from yourwwwdirectory to the live website to make the changes live. - Upload the
aaa-working.zip,resources.zipandwww.zipzipped files into your remote backup server. - Double-click the
ZZZZZZ__DESTOYER.batfile 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.batandzzzz_____spacer04.batfiles to prevent you from accidentally moving your mouse too far below thezzz02_wking_to_www.batfile and clicking on theZZZZZZ__DESTOYER.batfile which would delete all your work! Clicking thespacerfiles do nothing.