Renaming multiple file names inside a folder

  • Hi,

    I have a folder contains 3 files with 3 different file names ending _datestamp.txt.

    for example in my folder c:\filesfolder has companyAllDemo_09162014.txt, companyAllProd_09162014.txt & companyAllTrans_09162014.txt. i need to rename them & remove the date stamp, inside the same folder so the file names changes to companyAllDemo.txt, companyAllProd.txt & companyAllTrans.txt. any help, comment and feedback would be deeply appreciated.

  • I'd use a script task and make use of the methods in the My.Computer.FileSystem namespace.

  • Hi Grasshopper,

    i am very new in ssis and is there a way, i can get an example. i tried to search but everyone is moving files then renaming it.

  • Are you trying to automate this as a daily task or a one off?

    Personally I would create a script, either vbs or batch that renamed the files and schedule the script to run daily in task scheduler or an agent job, but that's just the way I have always done it.

  • not daily basis but i guess i also use c# script to rename the files. thanks everyone..i do appreciate everyone's input..

  • I suggest everyone to try KrojamSoft BatchRenameFiles program. It’s really work for me.

  • REN *_09162014.txt *.txt

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • Michael L John (1/3/2015)


    REN *_09162014.txt *.txt

    +1000. I love the "old ways". So simple.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply