Forum Discussion

  • SnowMan55's avatar
    SnowMan55
    Bronze Contributor

    XBenneboiX 

    Excel VBA code can do what you appear to desire.

     

    An assumption here is that your activity with such data will not violate Shopify's Terms of Service, e.g., section 1.9.  If in doubt, contact their legal department.


    In brief, your code would:

    1. Retrieve the file identifier (the existing filename, if such file exists) from a column B cell. I will assume that you are familiar with using the Range object of a Worksheet object, at least for accessing a single cell at a time.
    2. Detect the presence/absence of the file using VBA's Dir function. If the file is present, the function will return the filename and extension; if the file is not present, the function will return an empty string.  If the file exists...
    3. Retrieve the desired filename from the column A cell in the same spreadsheet row as the file identifier, again likely using a (different) Range object; and finally...
    4. Use VBA's Name statement to rename the file.

    All of those code steps would very likely be wrapped inside one For loop or one For Each loop to advance through the spreadsheet rows of interest.

    Some of your titles might contain characters that are not allowable in a filename.  If that's rare, you could just allow the execution of the code to stop (the default behavior if you do not include an error handler), and deal with that file manually, before or after resuming with the next execution of the loop.  Or you could write an error handler in your procedure to prompt you for an acceptable alternative name, and retry the Name statement.

     

Resources