Category: Code

Bulk Rename on SSH (FTP)

Really simple one, I need to bulk ‘find and replace’ a number of files within a folder, SSH connection with on OSX.

Example below searches for ‘that’ and replaces all instances with ‘this’.

for file in file_is_something_like_that*.jpg; do 
  mv "$file" "${file//that/this}"

Run that command and immediately the files are renamed.

Google Product Feed : Featured

Here’s a script for ‘Google Product Feed‘ by Ademti Software which allows you to subdivide a large feed (for later use in Google Ads) by the ‘featured’ option in Woocommerce. If the product is ‘featured’ then ‘custom_label_0’ will be populated with: ‘featured’. I thought it was worth sharing.

function lw_woocommerce_gpf_edit_custom_label_featured( $elements, $product_id, $variation_id = null ) {
if ( ! is_null( $variation_id ) ) {
$id = $variation_id;
} else {
$id = $product_id;
$featured_product_ids = wc_get_featured_product_ids();
if ( in_array( $id, $featured_product_ids ) ) {
$elements['custom_label_0'] = array( 'featured' );
} else {
$elements['custom_label_0'] = array( 'not_featured' );
return $elements;
add_filter( 'woocommerce_gpf_elements', 'lw_woocommerce_gpf_edit_custom_label_featured', 11, 3 ); } Update Etsy from CSV

Today, I want to introduce a nifty tool that’s been a game-changer for my Etsy shop: Drop-Edit. Picture this: managing your Etsy listings as effortlessly as tweaking a spreadsheet. That’s the magic of Drop-Edit. With just a CSV file, I can now oversee hundreds, theoretically thousands, of listings in my Etsy Shop. It’s like having a command center where I can tweak details, bulk edit, upload images, or switch up tags. It now handles bulk editing Etsy Listings for digital downloads.

The process is straightforward and efficient – a simple ‘Update on Etsy’ button links the tool to the Etsy API and, bingo, with my permission, it syncs with my Etsy shop. The instant updates are a huge time-saver.

And there’s more! This weekend, Drop-Edit (which is a subscription service) rolled out a brilliant new feature. Not only does it support Etsy>CSV, which is a lifesaver in itself, but now it also allows for bulk updating of digital downloads. Imagine the hassle saved! I managed to create and organize over 200 digital download listings on Etsy, seamlessly placing each digital item in its listing. Without Drop-Edit, this would have been a Herculean task, devouring time and patience.



Move WordPress Uploads Out of WordPress Directory

Here’s a simple one (which took me many hours to correctly configure). This little script, inserted into a custom plugin or functions.php in a child-theme will allow you to move your uploads folder out of the WordPress directory. Keeps things neat and tidy for my purposes.

Currently I have wordpress in its own directory, ie.

Now assume publicly facing url is, that makes my uploads – a terribly unprofessional looking URL.

With this code you can move the uploads directory to the top folder. Be sure to move the files, or use Better Search and Replace to change your DB if required.

function ($dirs) {
$new_upload_dir = '/home/domains/';
$new_baseurl = '';
$dirs['path'] = $new_upload_dir . $dirs['subdir'];
$dirs['basedir'] = $new_upload_dir;
$dirs['baseurl'] = $new_baseurl;
$dirs['url'] = $new_baseurl;
return $dirs;
15 // default is usually 10

Note: you’ll need to work out where ‘$new_upload_dir’ with some detective work of your own. Good luck!

Filter Insta Results by tag w/ Social Feed Gallery

Occasionally I build websites for folks. Recently I’ve been replacing stale old static galleries with a slim WordPress plugin that sync’s a users’ feed to a local cache and formats it in a nice way for the visitor. Its easier to update for the client (if they have a smartphone) and the visitor doesn’t need to be ab Instagram user or have any knowledge of that site to view.

The plugin I use is Social Feed Gallery by Quadlayers. It breaks less than other plugins I’ve used in the past, most of the time it isn’t their fault. Instagram’s API seems to chop-and-change.

Anyway- this isn’t an advert. If you want to display a selection of your Instagram images on your WordPress website but you’d like to filter out certain images (I do this by way of a hashtag #nosync ) then add this script to your CSS:

[data-item*="no-sync"] {display: none!important;}

Remember to tag the relevant items #no-sync, then hit the ‘Cache’ refresh button in your Social Feed Gallery dashboard panel. As Steve would have said *boom*. Discovered this solution at Stack Exchange, full of helpful humans who still beat AI!

FTP Transfer using SSH

Yesterday I learned how to migrate to a new web host in a very satisfyingly geeky way. If you are on Mac OS open up Terminal (enable the Homebrew theme) dim the lights, or block them out if possible, stick on the Matrix Soundtrack from 1998 and prepare to login to SSH! Its command line and slightly overwhelming.

SSH gives a user access to a remote machine so you can run commands on that server… as if you were in the room. Like scren sharing in the command line. When migrating loads of files from one remote place to another this is great as it saves us a step. Rather than transferring gigabytes of data from one remote server to our local machine to then forward on to another remote machine we just login and get the two remote machines to sort it out between themselves. Up here in the Scottish Highlands I’m on a community owned broadband network and I’m almost certain our local internet guru would have something to say about 100’s of gigabytes flying around so that was my reason for stumbling upon this magic code.