Skip to content

Tag: rename

How to remove text from file name for multiple files on Windows

On Windows, you can take advantage of PowerShell:

dir | rename-item newname { $_.name ireplace '(.+?) 203\.bmp$','$1.bmp' }

In this code snippet we use a command that removes ‘203’ from the file name.

Description

dir          => list the content of the current directory
 |           => send each found element to the next command
rename-item  => rename an element in a Windows PowerShell provider namespaceject
newname     => specify the name of the renamed file
{
    $_               => points to an object representing the actual file
   .name             => the name property of the automatic variable
   -ireplace         => perform a insensitive replace
   '(.+?) 203\.bmp$' => here comes the regex for matching the desired files
   '$1.bmp'          => the replacement string
}

You must run this command inside a power shell. Here is how to start it:

how to launch powershell on Windows 7?

Then cd into you dir from the Powershell window:

Change to the directory containing the files to be renamed from powershell window

More on http://stackoverflow.com/questions/21837836/how-to-rename-multiple-files-at-once-by-removing-a-varying-part-in-the-file-name

Also – http://superuser.com/questions/236820/how-do-i-remove-the-same-part-of-a-file-name-for-many-files-in-windows-7/871799

Problem with category slug renaming in WordPress

I had a problem. I couldn’t change the category slug in some of my categories. So I found the solution at:

http://wordpress.org/support/topic/category-slug-cant-be-updated

The problem comes from the fact that the tags and categories are stored in the same table in the database. And the tags also have slugs. So if there is already a tag with the slug that you want to put in the category you can’t do it until you delete the tag or change it’s slug.

You just need to go to the tags table in the admin panel and change the tag slug that’s making the problem.