Topic: FILE-REN.VDM -- An Extended File Renaming Utilit (1 of 13), Read 87 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Wednesday, August 11, 2004 04:24 PM


Based on my simple renaming macro posted yesterday in the "search and replace" conference I now wrote

FILE-REN.VDM -- An Extended File Renaming Utility


This utility lets you rename files using sophisticated search+replace expressions

The macro uses 'Regular Expressions', so you can't use the DOS/Windows wildcards here.
If you aren't familiar with that, please use VEDIT's online help (Topic "Regular expressions")

Example:
- Old name: test{.*}.txt
- New name: prod\1.doc
will rename all files beginning with 'test' and ending with '.txt' to 'prodxxx.doc'
where the 'xxx' is the appropriate part of the original name.


A button [Test] only lists the directory showing the planned renamings and reopens the dialog.
A button [Examples] opens a file with the following example expressions.
(That file is assumed to be in VEDITs user-macro directory.)

Since Regular Expressions may be a bit complicated it may help
to have some examples for usage with FILE-REN.VDM.

1) Renaming all .txt files to .doc files

Old name: {.*}.txt
New name: \1.doc

2) Renaming all .txt files to .doc files with additional name modification.
The leading text "test" should be renamed to "prod"

Old name: test{.*}.txt
New name: prod\1.doc

3) Files named like abc567.txt should be renamed to DATA-567.abc

Old name: {[a-z]+}{[0-9]+}.txt
New name: DATA-\2.\1

4) Add an additional digit to numbered files (Patrick Carroll's task)

Old name: {.* }{[0-9][0-9]}{[we]_}{.*}.jpg
New name: \10\2\3\4.jpg

Example:
IL03 016s 10w_001.jpg --> IL03 016s 010w_001.jpg
IL03 025n 015e_001.jpg (untouched)


Available here:
http://ziemski.privat.t-online.de/vedit/macros/file-ren.vdm
http://ziemski.privat.t-online.de/vedit/macros/file-ren.syn
http://ziemski.privat.t-online.de/vedit/macros/file-ren.txt



Christian

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Utilit (2 of 13), Read 66 times
Conf: VEDIT Macro Library
From: Ted Green
Date: Wednesday, August 11, 2004 10:35 AM

At 08:24 AM 8/11/2004, you wrote:
>Based on my simple renaming macro posted yesterday in the "search and replace" conference I now wrote
>FILE-REN.VDM -- An Extended File Renaming Utility

Christian:

Thank you for handling this customer's "request" so thoroughly. And thank you for answering all questions here while I am still so busy. (Wife and kids are going on summer vacation tomorrow without me.)

Ted.

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Utilit (4 of 13), Read 67 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Wednesday, August 11, 2004 04:21 PM

On Wed, 11 Aug 2004 10:35:00 -0400, Ted Green wrote:

>Thank you for handling this customer's "request" so thoroughly.

Oh, that renaming utility was on my to-do list since a long time.
I need it for myself too...

>And thank you for answering all questions here while I am
>still so busy.

You are welcome.
It's fun for me to be here.

And of course: The more time you have exclusively for SSH these days
the earlier you will be able to continue with VEDIT someday ;-)


Christian

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Utilit (3 of 13), Read 69 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Wednesday, August 11, 2004 04:21 PM


And here is the first update.

1) Now it's possible to choose to select the filenames
case-sensitive or not.

2) And you optionally can force the new names to lower or UPPER case.

You may ask:
What should that be good for?
Windows handles filenames case-insensitive!

That is halfway correct. But even in Windows the filenames are stored
case-sensitive.

And so for example when uploading files to an FTP server (e.g. Web
server) it is important to have the correct character case, exactly
matching with the links in the HTML files corresponding to them.
Many (most?) Web servers are running UNIX and are case-sensitive.

With this macro you can make your filenames consistently all upper or
lower case.


3) When using the "Test" function the new (renamed) files are
displayed highlighted via a Syntax highlighting file.

The new files are available here:

http://ziemski.privat.t-online.de/vedit/macros/file-ren.vdm
http://ziemski.privat.t-online.de/vedit/macros/file-ren.syn
http://ziemski.privat.t-online.de/vedit/macros/file-ren.txt


Christian

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Utilit (5 of 13), Read 72 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Thursday, August 12, 2004 08:46 AM


Next update:

// nicer file listing (optically)
// some bug fixes
// [Test] is now default button


http://ziemski.privat.t-online.de/vedit/macros/file-ren.vdm


Christian

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Utilit (6 of 13), Read 58 times
Conf: VEDIT Macro Library
From: Patrick Carroll
Date: Wednesday, September 01, 2004 11:05 AM

Christian,

Wow! I am impressed.

Not only did you point me in the right direction, but you built the path in front of me. The macro works great.

Thank you very much,

Patrick Carroll

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Utilit (7 of 13), Read 46 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Tuesday, September 07, 2004 07:08 AM


The macro is now renamed to ren-file.vdm

http://ziemski.privat.t-online.de/vedit/macros/ren-file.vdm

It no longer needs the additional files from older versions.
They are automatically created when the macro runs.

Christian

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Ut (8 of 13), Read 39 times
Conf: VEDIT Macro Library
From: Peter Rejto
Date: Thursday, September 23, 2004 11:27 PM

Christian,

I am using Vedit 6.13; 09/07/04; and I am missing something simple about the {Misc, More macros, REN-FILES} command.

Specifically I would like to rename all files in the directory in which I opened Vedit as follows:

old name : web;products_c=01234.html
new name: products_c=01234.html

I tried, following your examples,

old name web;{*.*}
new name \1

I have a hunch that I am missing something really simple about regular expressions.

Thanks again,

-peter.

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Ut (9 of 13), Read 38 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Friday, September 24, 2004 02:44 AM

Peter:

On 9/23/2004 11:27:29 PM, wrote:
>
>Specifically I would like to rename all files in the
>directory in which I opened Vedit as follows:
>
>old name : web;products_c=01234.html
>new name: products_c=01234.html
>
>I tried, following your examples,
>
>old name web;{*.*}
>new name \1
>
>I have a hunch that I am missing something really
>simple about regular expressions.

Indeed: You can't use DOS/Windows wildcards.
So the "*.*" is wrong.
To be precise: The first "*" is the problem.

Quote from Vedit's help:

" * Matches zero or more occurrences of the preceding character (or list)."

The word "preceding" is the important one. In your case the first asterisk doesn't have a preceding expression and so Vedit complains.


Try it this way:

old name web;{.*}
new name \1


Christian

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Ut (10 of 13), Read 34 times
Conf: VEDIT Macro Library
From: Peter Rejto
Date: Friday, September 24, 2004 12:08 PM

On 9/24/2004 2:44:10 AM, Christian Ziemski wrote:
>Peter:

>Indeed: You can't use DOS/Windows
>wildcards.
>So the "*.*" is wrong.
>To be precise: The first "*" is the
>problem.
>
>Quote from Vedit's help:
>
>" * Matches zero or more occurrences of
>the preceding character (or list)."
>
>The word "preceding" is the important
>one. In your case the first asterisk
>doesn't have a preceding expression and
>so Vedit complains.
>
>
>Try it this way:
>
>old name web;{.*}
>new name \1

Thanks Christian;

This is exactly that I have missed.

Actually, my original problem was slightly more complicated. This complication was due to the fact that I had an additional . in my filename.

So, I ended up using

old name web;{products.*.html}

The new name did not need any adjustment.

This seems to work like a charm!

You really helped me out.

Thanks again.

-peter.

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Ut (11 of 13), Read 10 times
Conf: VEDIT Macro Library
From: Peter Rejto
Date: Saturday, October 29, 2005 01:29 AM

On 9/7/2004 7:08:06 AM, Christian Ziemski wrote:
>
>The macro is now renamed to
>ren-file.vdm
>
>http://ziemski.privat.t-online
>.de/vedit/macros/ren-file.vdm
>
Christian,

I tried to download your utility, but got an error message.

Thanks,

-peter.

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Ut (12 of 13), Read 8 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Saturday, October 29, 2005 12:31 PM

On Sat, 29 Oct 2005 01:29:00 -0400, Peter Rejto wrote:

>>http://ziemski.privat.t-online.de/vedit/macros/ren-file.vdm
>
>I tried to download your utility, but got an error message.

Peter:

My Vedit fan page moved to http://www.ziemski.net/vedit

Christian

 


Topic: Re: FILE-REN.VDM -- An Extended File Renaming Ut (13 of 13), Read 10 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Wednesday, November 02, 2005 03:08 PM

On Sat, 29 Oct 2005 01:29:00 -0400, Peter Rejto wrote:

>On 9/7/2004 7:08:06 AM, Christian Ziemski wrote:
>>
>>The macro is now renamed to ren-file.vdm
>
>I tried to download your utility, but got an error message.

Peter:

I forgot to mention:

It is no longer needed to download that macro separately.

Since September 2004 or so it's function is reachable via menu:
{MISC, More macros, REN-FILES}

(And the macro itself is in the \vedit\macros\ directory.)

Christian