Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Changing suffix of filename  (Read 5842 times)

0 Members and 1 Guest are viewing this topic.

netwerkassist

    Topic Starter


    Rookie

    Changing suffix of filename
    « on: May 30, 2014, 08:10:59 PM »


    down vote

    favorite


     


    I've got a file that gets copied daily from one sql system to the another sql server for restore purposes. The file name contains the name of the sql backup along with the current date/time. I would like to strip out the date/time and rename as follows:

    Typical File copied daily: Server100_PRD_FULL_20140530_000850.bak 

    --But not sure how to rename the suffix that contains the date.

    Would like to rename copied files as above to:SPDBSPSFS100_FS84PRD_FULL.BAK

    Appreciate help.

    Thanks
     

    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: Changing suffix of filename
    « Reply #1 on: May 31, 2014, 03:51:10 AM »
    See if this helps:

    Code: [Select]
    @echo off
    set "file=Server100_PRD_FULL_20140530_000850.bak"
    for /f "tokens=1-3 delims_=" %%a in ("%file%") do set "file=%%a_%%b_%%c.bak"
    echo("%file%"


    It depends on how you get your file - you've stated that you want to strip out the date_time and also that you want to give it a different filename.

    I'm not sure exectly what you are after.

    netwerkassist

      Topic Starter


      Rookie

      Re: Changing suffix of filename
      « Reply #2 on: May 31, 2014, 08:30:19 AM »
      Thanks....one note the file name changes daily ( as per date/time file created) so today would be:

      Server100_PRD_FULL_20140530_000850.bak

      tomorrow

      Server100_PRD_FULL_20140531_000850.bak

      Thanks

      foxidrive



        Specialist
      • Thanked: 268
      • Experience: Experienced
      • OS: Windows 8
      Re: Changing suffix of filename
      « Reply #3 on: May 31, 2014, 08:47:43 AM »
      It is not clear what you want to do, and how you go about doing it.

      Which drive, folder, is it on a network and do you need to log into the LAN?

      Squashman



        Specialist
      • Thanked: 134
      • Experience: Experienced
      • OS: Other
      Re: Changing suffix of filename
      « Reply #4 on: May 31, 2014, 10:55:54 AM »
      The script Foxi gave you is the base code to remove the date. Pretty sure you can extrapolate from there on how to rename your file from there.