Share via

Batch renaming of files via batch file or other means

Anonymous
2015-03-02T15:08:50+00:00

I have several hundred .pdf files and would like to rename them by deleting the first 10 characters of each file name.

Is there a .bat file or an easy way to do this?

Thanks very much.

All of the first 10 characters of each file name are the same.

Windows for home | Previous Windows versions | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. @CmdrKeene 90,621 Reputation points Volunteer Moderator
    2015-03-03T21:15:55+00:00

    I like this PowerShell command, but it only works if you're taking the same thing out of every file name.

    Get-Item .\*.* | ForEach-Object { Rename-Item $_ ($_.Name -replace "a", "b") }

    This gets a list of all files in a folder, then for each one, replaces the letter A with the letter B anywhere in the file name.  Obviously you can tweak it how you like to replace " - copy" with "" (null empty string), or anything else.  I use this often.

    1 person found this answer helpful.
    0 comments No comments

Answer accepted by question author

  1. Anonymous
    2015-03-02T23:07:01+00:00

    Hi,

    How to Batch Rename Files in Windows: 4 Ways to Rename Multiple Files

    http://www.howtogeek.com/111859/how-to-batch-rename-files-in-windows-4-ways-to-rename-multiple-files/

    Batch Files

    http://commandwindows.com/batch.htm

    You can use an IF Errorlevel to check to see if the conditions exist to loop

    back or to stop the process. Use Labels.

    Errorlevels

    http://www.robvanderwoude.com/errorlevel.php

    A lot of help can be found for Batch Files using BING or Google.

    Hope this helps.

    If Statements

    http://www.robvanderwoude.com/if.php 

    Branching with IF statements.

    http://commandwindows.com/batchfiles-branching.htm

    Wildcards :

    *    =    everything/all places

    ?    =    just one place

    ren "xyz123_*.wav" ?????.wav

    Would rename  xyz123_*.wav files to the FIRST five places of the original file name. However

    it would only process the first file since all others would be end up with duplicate names.

    ===========================================================

    Powershell scripting is another option ;

    Windows PowerShell

    http://technet.microsoft.com/en-us/library/bb978526.aspx

    Scriptiing with Windows PowerShell

    http://technet.microsoft.com/en-us/scriptcenter/dd742419

    PowerShell - Introduction

    http://commandwindows.com/powershell.htm

    Windows PowerShell

    http://msdn.microsoft.com/en-us/library/aa973757(VS.85).aspx

    Windows PowerShell Owner's Manual

    http://technet.microsoft.com/en-us/library/ee221100.aspx

    Scripting with Windows PowerShell & Download Link

    http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx

    How Do I: Windows PowerShell 2.0?

    http://technet.microsoft.com/en-us/windows/dd320288.aspx 

    Windows PowerShell

    http://en.wikipedia.org/wiki/Windows\_PowerShell

    Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0)http://support.microsoft.com/kb/968929

    How to Open Windows PowerShell in Windows 7

    http://www.sevenforums.com/tutorials/27758-windows-powershell.html

    Hope this helps.


    Rob Brown - Microsoft MVP <- profile - Windows Experience : Bicycle - Mark Twain said it right.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2015-03-03T21:08:42+00:00

    The very easiest way to do this is to download the freeware "Bulk Rename Utility".

    It has a section that will remove the first "n" characters of all selected filenames.

    Bulk Rename Utility

      < http://www.bulkrenameutility.co.uk/Download.php >

    HTH,

      JW

    0 comments No comments
  2. @CmdrKeene 90,621 Reputation points Volunteer Moderator
    2015-03-02T22:58:38+00:00

    Is the first 10 characters the same on every file?  Let me know -- I have a command that can do a very easy mass-replacement, but it would need to be the same on every file.

    If it's not the same, let me know, there's an alternative but takes a little longer.

    0 comments No comments