Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Dec 2000
    Calgary, Alberta, Canada
    Thanked 1 Time in 1 Post

    Question Renaming multiple files

    I have a number of files that have a date at the front of their name, e.g. 20120130-filename01...20120201-filename32, etc. I want to rename the files so that I retain the file name, but lose the prefix date. I figure that there must be a way to do this, but I haven't done a lot of editing stuff in Windows for a long time and have obviously forgotten how - I am using Win 7, but this is most likely a "General Windows" question. Maybe it can't be done, but I am hoping it is something relatively simple. Any insight that anyone can provide will be greatly appreciated. Thanks.

    Ron M

  2. #2
    4 Star Lounger
    Join Date
    Jun 2011
    Hampshire (the old one)
    Thanked 71 Times in 61 Posts
    The only way I can think of is to select all the files you want to rename, press F2, and type a name. This will rename them filename, filename(1), filename(2), and so on. Probably not quite what you want.

  3. #3
    3 Star Lounger
    Join Date
    Apr 2010
    Los Gatos CA
    Thanked 12 Times in 11 Posts
    I would suggest Lupas Rename, Google it. It's an old program, but it is free, and it works. You can re-name any number of files, specifying a format, it gives you a preview of what the files will be named just in case you got something wrong, then click on Rename and it's done.

  4. #4
    5 Star Lounger
    Join Date
    Jan 2010
    Los Angeles, CA
    Thanked 38 Times in 34 Posts
    Here is a PowerShell script that will do this renaming for you:

    param (
      [string]$directory = ".",
    [string]$regex = "^\d{6,8}-"
    function checkForDuplicate($file, $newBaseName) {
      $result = $file.Directory.FullName + "\" + $newBaseName + $file.Extension
      if ([System.IO.File]::Exists($result)) {
        $i = 1
        do {
          $result = $file.Directory.FullName + "\" + $newBaseName + "_" + $i + $file.Extension
        } while ([System.IO.File]::Exists($result))
    filter startsWithDate() {
      $baseName = $_.BaseName
      if ($baseName -match $regex) {
        $newBaseName = $baseName -replace $regex,""
        $newName = checkForDuplicate $_ $newBaseName
        if ($whatIf) {
          $newFile = [System.IO.FileInfo]$newName
          "Would have renamed " + $_.FullName + " to " + $newFile.Name
        } else {
          if (!$quiet) {
            $newFile = [System.IO.FileInfo]$newName
            "Renaming " + $_.FullName + " to " + $newFile.Name
    $count = 0
    Get-ChildItem $Directory -Recurse -Force | startsWithDate
    "Renamed $count files"
    To use this, save the above text into a file such as rename.ps1. Then open a PowerShell command line, cd to the directory containing the script, and enter:

    .\rename.ps1 c:\directory\containing\your\files\to\rename

    and it will rename the files in that directory and all subdirectories, letting you know the new name for each file.

    The script is set up to handle both 6 and 8 digit dates. The script also checks for duplicate names. For example, if you have 20120209-proposal.docx and 20120208-proposal.docx, it will rename one of them to proposal.docx and the other to proposal_1.docx.

    You can also pass the -whatif argument and the script will tell you what it would rename files to, but not actually do any renaming:

    .\rename.ps1 c:\directory\containing\your\files\to\rename -whatif

    There is one glitch with the -whatif capability - since the files are not really being renamed, the script will not notice potentially duplicate names. For example, it will tell you that both of the example files from above will be renamed proposal.docx.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts