Computing.Net > Forums > Programming > Batch file commands help !

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file commands help !

Reply to Message Icon

Name: anamica
Date: February 7, 2008 at 06:43:48 Pacific
OS: windows xp
CPU/Ram: 256 mb
Product: hp1440
Comment:


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.0500368

Prefixes 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.0500368

Any help in this regards is greatly appreciated.

Thanks, Anamica




Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: February 7, 2008 at 08:23:47 Pacific
Reply:

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


0

Response Number 2
Name: anamica
Date: February 7, 2008 at 09:27:01 Pacific
Reply:

Thank you very much :-) It worked like a charm!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file commands help !

Simple Batch File command help www.computing.net/answers/programming/simple-batch-file-command-help/16568.html

Batch File Commands (HELP PLZ!) # 2 www.computing.net/answers/programming/batch-file-commands-help-plz-2/16085.html

Batch File Commands (HELP PLZ!) www.computing.net/answers/programming/batch-file-commands-help-plz/16063.html