Saved Bookmarks
| 1. |
Solve : Changing suffix of filename? |
|
Answer» 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 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.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 ThanksIt 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?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. |
|