Bogiecom.com
  • About
  • Magento
  • Sitecore
  • WordPress

Monthly Archives: November 2011

Imagick Powershell Resize Images In Folder

Posted on November 18, 2011 by bc-admin

Here’s a quick one-liner to re-size photos if you have Imagick installed using PowerShell. It also renames the files with the dimensions specified:

1
2
PS C:\Users\SloshDev> gci("*.jpg") |
      %{convert  $_.FullName -resize 500x500 $_.Name -replace '\.jpg$','-500x500.jpg'}

Ultimately ended up with this to rename the file based on the actual dimensions of the file in the end:

1
2
PS C:\Users\SloshDev> gci("*.jpg") |
   %{convert $_.FullName -resize 500x500 -set filename:area '%wx%h' ($destination + ($_.Name.Trim("\.jpg") + "-%[filename:area].jpg"))}

This is great if you want to do this within the file itself, however if you need to specify dimensions, source and destination directories, and specific image file extensions you could use a script like this:

1
2
3
4
5
6
7
$source = 'C:\User\SloshDev\My Pictures\'
     $destination = 'C:\User\SloshDev\My Pictures\500's\'
     $ext = "jpg"
     $size = "500x500"
     #Resize Images
      gci("$source*.$ext") |
        %{convert $_.FullName -resize $size -set filename:area '%wx%h' ($destination + ($_.Name.Trim("\.$ext") + "-%[filename:area]." + $ext))}

Posted in Image Resizing, Imagick, Powershell | Leave a comment |

Append Extension to All Files in Directory

Posted on November 11, 2011 by bc-admin

IIS 6.0 did not save configuration files with “.xml” extension automatically. So I needed to add the .xml to the files. So this is what I did:

1
PS C:\_old-IIS-site-configurations> Get-ChildItem *.com | Rename-Item -NewName { $_.Name + ".xml"; }

Nice, quick one-liner to quickly eliminate what would be a pain otherwise.

Posted in Powershell, Rename-Item | Leave a comment |

Miva Merchant Product Attribute Export – Update Pricing with Powershell

Posted on November 9, 2011 by bc-admin

If you’ve ever wanted a tab delimited list of product attributes and prices to update pricing, here’s one way:

Export product attributes through ‘Utilities > Export Data > Export Attributes to XML File’

  1. When exporting choose ‘Replace All Mode
  2. You will have to add a root level element around the xml generated by miva and the file:

    1
    2
    PS C:\>$a = Get-Content .\provide.xml
    PS C:\>Set-Content .\provide.xml -value "<products>",$a,"</products>"      

    Now bring in file as xml:

    1
    PS C:\>$xml = [xml] (Get-Content .\provide.xml)

    Run this command to generate a tab delimited list of Product_Code, Code, & Price

    1
    2
    PS C:\>$xml.Products.ProductAttributeOption_Add |
                   foreach { $_.product_code + "`t" + $_.Price } > .\provide-list.txt

    For more information on Powershell’s xml capabilities and how easy it is to use XML with Powershell visit Powershell XML on Code Project

    .

Posted in Miva Merchant 5.5, Powershell, Updating Product Attributes, XML | Leave a comment |

Grooveshark Konami Code

Posted on November 9, 2011 by bc-admin

If you’re a fan of Grooveshark…

Give the Konami Code a try.

Would you like to see what other sites have some Konami effects? Check out Konami Code Sites.

If you use YUI on your site, there’s a built-in event for handling the Konami Code… see YUI Konami Event by Luke Smith

Posted in Grooveshark, Konami Code, Video Games, YUI Konami Event | Leave a comment |

Magento Custom Form Field Validators using Prototype (MySQL Date Format)

Posted on November 9, 2011 by bc-admin

Here I needed to make sure that the user input was formatted correctly for a MySQL database. The javascript calendar code was set to automatically input the date into the text field in the correct format, but the user still had the option to type it in manually. This was the Prototype validator I used to verify that the user had entered it correctly as ‘YYYY-MM-DD’:

1
2
3
4
5
<script type="text/javascript">
  Validation.add('required-date-format','Please Enter date as YYYY-MM-DD. Click the calendar icon to select a date.', function(v) {
       return  !Validation.get('IsEmpty').test(v) && /^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9])$/.test(v);  });
       var warrantyregistrationForm = new VarienForm('warrantyregistrationForm', true);
</script>

Posted in Custom Field Validator, Date Format, Magento, MySQL | Leave a comment |

Pages

  • About
  • Magento
  • Sitecore
  • WordPress

Archives

  • January 2017
  • December 2013
  • November 2013
  • February 2013
  • January 2013
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • November 2011
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • September 2009

Categories

  • .NET
  • Air Force
  • Apache Configuration
  • Bash
  • C#
  • Comma-Delimited
  • Custom Field Validator
  • Date Format
  • Dump Files
  • Files
  • Grep
  • Grooveshark
  • HTML
  • Image Resizing
  • Imagick
  • Integration
  • jQuery
  • Konami Code
  • Linux
  • Magento
  • Magento Third Party CMS Integration
  • Mini Shuttle
  • Miva Merchant 5.5
  • MySQL
  • PHP
  • Powershell
  • Regular Expressions
  • Rename-Item
  • Sed
  • Shell Scripting
  • Sitecore
  • Strings
  • Uncategorized
  • Updating Product Attributes
  • Video Games
  • Wordpress
  • X-37
  • XML
  • YUI Konami Event

CyberChimps WordPress Themes

© 2008 - 2016 Bogiecom.com