Batch file to tidy file names

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Batch file to tidy file names

Post by John Gray »

agibsonsw wrote:I'm sure you're right and it looks very sexy. Is there a secret coven for people who know this stuff?
Sure is! I am the Coven-anter.
agibsonsw wrote:But what about a PowerShell example?
That be new-fangled stuff which I'm too olde to learn...
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Batch file to tidy file names

Post by agibsonsw »

agibsonsw wrote:Thanks. I chose VbsEdit. Looks great: intelli-sense, code completion, debugging, help system. I got over-excited!
I spoke too soon. This app requires registration to sensibly step through code (otherwise it takes an age) which costs $59 dollars. I will rarely use this
app so I think I'll search again.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Batch file to tidy file names

Post by agibsonsw »

I might stick with Notepad++. Can it be more fully configured for VB Script? Function arguments, object library help?

Alternatively, could I use VB.Net Express 2010 to create a script file?

Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78463
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Batch file to tidy file names

Post by HansV »

The VBScript help file is available from Windows Script 5.6 Documentation.

There's a Notepad++ plugin that lets you associate an extension (.vbs in this case) with a help file so that you get context-sensitive help: LanguageHelp from npp_plugins - fstellari2.
Best wishes,
Hans

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Batch file to tidy file names

Post by agibsonsw »

Thanks for this.
I donloaded the .chm help file but it doesn't work. It opens with a blank page 'Navigation to webpage failed'. I tried configuring it wthin Notepad++
but the problem persists.
I think I came across a similar problem ages ago but can't remember if I resolved it. I'm on Vista Home Premium SP2 if anyone has come across a similar
problem. Ta, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Batch file to tidy file names

Post by agibsonsw »

I just remembered - I need to unblock it. It works fine now thanks. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Batch file to tidy file names

Post by agibsonsw »

If anyone is interested, here is a PowerShell solution:

Code: Select all

Function Rename-Files ($path, $extn)
{
    Get-ChildItem $path $extn | 
    ForEach-Object { 
        $new = $_ -replace " ", "_"  
        $new = $new -replace "-", "_" 
        Rename-Item $_.fullname ($_.path + $new)
    }
} # end of function

Rename-Files "C:\Users\Andrew\Pictures\Essen\32x32" "*.png"
I'm only posting this because I was quite pleased with it. It was my first attempt to write a PS script!
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78463
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Batch file to tidy file names

Post by HansV »

Good for you!
Best wishes,
Hans