Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,I need some help with the batch file commands; I have an 'invoice' directory which will have files with below names.
IMPORT_INVOICE_FILEfsbc.20080108.0500368
IMPORT_INVOICE_FILEcount.sbc.20080108.0500368Prefixes in both the files IMPORT_INVOICE_FILEfsbc. , IMPORT_INVOICE_FILEcount.sbc. will always be same, only the timestamp (YYYYMMDD.HHMMSS) varies from day to day files.
I would like to copy both these files to a different directory with names like below, just by stripping the prefix (IMPORT_INVOICE_FILE)
fsbc.20080108.0500368
count.sbc.20080108.0500368Any help in this regards is greatly appreciated.
Thanks, Anamica

The following batch does the job; replace MY_DIRECTORY with the folder holding the files and NEW_DIRECTORY with the target one.
@Echo Off
SetLocal EnableDelayedExpansion
PushD MY_DIRECTORY
For %%j in (IMPORT_INVOICE_FILE*.*) Do (
Set file=%%j
Set file=!file:IMPORT_INVOICE_FILE=!
Copy %%j NEW_DIRECTORY\!file!
)
PopD
:: End_Of_Batch

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |