Topic: Search and replace file names. (1 of 5), Read 67 times
Conf: Search and Replace
From: Patrick Carroll
Date: Tuesday, August 10, 2004 11:51 AM

Can someone point me in the right direction for a macro which will search a directory and rename files.

I have a directory with several thousand files. The files do not have a consistent naming methodology which I want to correct.

For example I have files which look like the following:

IL03 016s 10w_001.jpg
IL03 025n 015e_001.jpg


I want to be able to search each of the file names and test to see if the name has a three digit numeric code in front of the alpha code "w" or "e". If the file has a two digit code then I want to add a "0" at the beginning of the numeric code. If the file has a three digit code then the file will not be renamed.

Any help would be appreciated.

Thanks,

Pat

 


Topic: Search and replace file names. (2 of 5), Read 58 times, 1 File Attachment
Conf: Search and Replace
From: Christian Ziemski
Date: Tuesday, August 10, 2004 03:58 PM

On Tue, 10 Aug 2004 11:51:00 -0400, Patrick Carroll wrote:

>Can someone point me in the right direction for a macro which will
>search a directory and rename files.
>
>I have a directory with several thousand files. The files do not
>have a consistent naming methodology which I want to correct.

Patrick:

I tried to describe one possible solution in words.
But then realized that it nearly was pseudo code.

And so I deleted my posting again and rewrote it in VEDIT macro language.

It's attached as ready-to-run macro.

But of course you have to change it regarding your directory name
and you should test it before using it in production environment!!!
For easier testing I included some lines (and I disabled the Rename-command for security ...)

The macro is documented. So you should be able to understand its technique. If you have any questions: let us know here.


Christian

 
GETDIR.VDM (1KB)

 


Topic: Search and replace file names. (3 of 5), Read 58 times
Conf: Search and Replace
From: Ian Binnie
Date: Wednesday, August 11, 2004 02:38 AM

On 8/10/2004 3:58:30 PM, Christian Ziemski wrote:
>On Tue, 10 Aug 2004 11:51:00 -0400,
>Patrick Carroll wrote:
>
>>Can someone point me in the right direction for a macro which will
>>search a directory and rename files.
>>
>>I have a directory with several thousand files. The files do not
>>have a consistent naming methodology which I want to correct.
>
>Patrick:
>
>I tried to describe one possible
>solution in words.
>But then realized that it nearly was
>pseudo code.
>
>And so I deleted my posting again and
>rewrote it in VEDIT macro language.
>
>It's attached as ready-to-run macro.
>
>But of course you have to change it
>regarding your directory name
>and you should test it before using it
>in production environment!!!
>For easier testing I included some lines
>(and I disabled the Rename-command for
>security ...)
>
>The macro is documented. So you should
>be able to understand its technique. If
>you have any questions: let us know
>here.
>
>
>Christian

Christian's macro will create a list of changed filenames, but lacks some essential error checking.

You may wish to include the following in Christian's macro.

if(File_Exist(@(104))==0)
{
File_Rename(@103,@104)
}
else // make name unique or display error
{

}
Return

 


Topic: Search and replace file names. (4 of 5), Read 64 times
Conf: Search and Replace
From: Christian Ziemski
Date: Wednesday, August 11, 2004 12:02 PM

On 8/11/2004 2:38:10 AM, Ian Binnie wrote:
>
>Christian's macro will create a list of
>changed filenames, but lacks some essential error checking.
>
A bit to do for Patrick. He only wanted to be pointed into one direction ... ;-)

But you are correct. There is no error handling in this simple macro.

Today I wrote a new, much more flexible renaming macro.
I posted it in the "Macro Library" conference.

Christian

 


Topic: Search and replace file names. (5 of 5), Read 49 times
Conf: Search and Replace
From: Steve Rawling
Date: Saturday, October 23, 2004 10:07 PM

Patrick.

As a text editor, Vedit is not the tool I would be turning to for renaming files. Still, Christian has shown that vedit is up to the challenge.

I would turn to my file manager to do this task. Luckily I don't use explorer, but rather ZtreeWin which has a a powerful suite of rename tools which are accessed by an interface/paradigm which IMO is more applicable to the renaming task.

Mind you I have in the past used Ztreewin's Batch command to make a file of the format
rename filename1.txt filename1.txt
rename filename2.txt filename2.txt
etc..
...

and then have used Vedits powerful search and replace options to edit the second occurrence of the file name on every/any line

Steve