1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Updating Multiple Filenames

Discussion in 'DOS/Other' started by hutabarat, Apr 10, 2010.

Thread Status:
Not open for further replies.
Advertisement
  1. hutabarat

    hutabarat Thread Starter

    Joined:
    Apr 10, 2010
    Messages:
    3
    Hi,

    For simplicity, I have the following files:

    ABC DEF 01_2000.TXT
    ABC DEF 02_2000.TXT
    ABC DEF 03_2000.TXT
    ABC DEF 04_2000.TXT

    in C drive.

    The result that I want is like this:

    ABC DEF 01.TXT
    ABC DEF 02.TXT
    ABC DEF 03.TXT
    ABC DEF 04.TXT

    So, you can see that I just need to remove the string "_2000" from each filename.

    After searching in the internet, I read that in order to perform a loop I can use FOR command.
    But, I am still baffled how to use it.
    Any help is appreciated.

    Many thanks.

    Leo
     
  2. Mumbodog

    Mumbodog

    Joined:
    Oct 3, 2007
    Messages:
    7,889
  3. TheOutcaste

    TheOutcaste

    Joined:
    Aug 7, 2007
    Messages:
    9,028
    Lot's of rename utilities like the one Mumbodog linked.

    For a batch file, this will do it:
    Code:
    @Echo Off
    SetLocal EnableDelayedExpansion
    Set _Source=[COLOR=Red]C:\My File Folder Path Goes Here[/COLOR]
    PushD "%_Source%"
    For /F "Tokens=* Delims=" %%I In ('Dir /A-D /B *.txt') Do (
    Set _Fname=%%~nI
    Set _Fname=!_Fname:_2000=!
    Ren "%%~I" "!_Fname!%%~xI"
    )
    PopD
     
  4. hutabarat

    hutabarat Thread Starter

    Joined:
    Apr 10, 2010
    Messages:
    3
    Hi,

    Thank you all for the replies.

    I will look into it.

    Regards,

    Leo
     
  5. hutabarat

    hutabarat Thread Starter

    Joined:
    Apr 10, 2010
    Messages:
    3
    Hi TheOutcaste,

    Your script works perfectly.

    Once again many thanks.

    Regards,

    Leo
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/916113

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice