Page 1 of 1

Renaming a long file name

PostPosted: Tue Jul 03, 2012 1:35 am
by Fonz
Hi
I am new to BRC and would like help with the following (Syntax please showing the order of execution rather than a description)

I have a folder C:\Client Registration\Excel Files

There are lots of XLSX and PDF files in this folder and I want to change/rename ONLY the XLSX files in the folder.

Here is a few typical file names and what I would like then renamed to:
" AD106 MOTOR INDUSTRY (PVT) LIMITED) - 123456789 INVOICE 2012-06-30.xlsx"
" AD3 LIBERTY MOTOR INSURANCE GROUP - 123654987 INVOICE 2012-06-25.xlsx"
(all names above are fictitious)

--> file should be rename AD106.xlsx, AD3.xlsx...etc.

What I am trying to do is extract the first part of the name (like AD106 OR AD3 - it is not a fixed number of characters ) which is a code and trim all spaces from it whilst keeping the same XLSX extension - remember this folder also contains PDFs which may or may not have the same file name and I want to ONLY rename the xlsx files.

Thanks for any help given.
Regards
Fonz

Re: Renaming a long file name

PostPosted: Thu Aug 02, 2012 7:40 pm
by Stefan
Fonz wrote:Hi
I am new to BRC and would like help with the following (Syntax please showing the order of execution rather than a description)

I have a folder C:\Client Registration\Excel Files

There are lots of XLSX and PDF files in this folder and I want to change/rename ONLY the XLSX files in the folder.

Here is a few typical file names and what I would like then renamed to:
" AD106 MOTOR INDUSTRY (PVT) LIMITED) - 123456789 INVOICE 2012-06-30.xlsx"
" AD3 LIBERTY MOTOR INSURANCE GROUP - 123654987 INVOICE 2012-06-25.xlsx"
(all names above are fictitious)

--> file should be rename AD106.xlsx, AD3.xlsx...etc.

What I am trying to do is extract the first part of the name (like AD106 OR AD3 - it is not a fixed number of characters ) which is a code and trim all spaces from it whilst keeping the same XLSX extension - remember this folder also contains PDFs which may or may not have the same file name and I want to ONLY rename the xlsx files.

Thanks for any help given.
Regards
Fonz




>> I want to ONLY rename the xlsx files.
use /PATTERN:"*.xlsx"

Note: i think BRC is case sensitive here and don't work on e.g. *.XLSX with that pattern.


- - -

FROM:
"AD106 MOTOR INDUSTRY (PVT) LIMITED) - 123456789 INVOICE 2012-06-30.xlsx"
"AD3 LIBERTY MOTOR INSURANCE GROUP - 123654987 INVOICE 2012-06-25.xlsx"

TO:
AD106.xlsx
AD3.xlsx

I think it's not possible with BRC since there is no RegEx support included:
FInd: (.+?) .*
Replace: \

.