VBS Script Help

Hi, I'm not sure if this is the correct forum or not. If not, please let me know where to post.

I would like to create a script that will rename files based on a users input. So far I have a basic batch file that will do the job, but I want something that they wont have to edit.

The files needing to be renamed are usually something like 06M123AB.000 where the 123 would be the only thing renamed in the folder.

I would like to, if possible, let the user input the old numbers (123)  then input the new numbers (456) and have all files in the current directory renamed. I was thinking a VB Script would be better for this.

Thanks for the help.

 

 

 

 

 



Answer this question

VBS Script Help

  • ssfftt

    i suppose you could use script.

    but i would think this is pretty easy.

    1) get all files from the directory that match the file mask provided
    2) loop through all files and do logic for each file to find the new name, and rename the file by moving it


    dim theFiles as FileInfo()
    dim theFile as FileInfo

    theFiles = New DirectoryInfo(CurDir).GetFiles("*" & arguments & "*")

    for each theFile in theFiles
    'logic to find new name
    theFile.MoveTo(NewName)
    Next



  • alka_mehta

    the best place to ask VBScript questions is here:

    http://www.microsoft.com/technet/community/newsgroups/topics/scripting.mspx

    Since these forums are for .NET, specifically VB.NET, development

    Thanks



  • NickNotYet

    Thanks for pointing me in the right direction.
  • VBS Script Help