Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I would like to rename all files in \\gbrcrotpc8ms008\rss_data_transfer_gb77$\interface\planning_Reports in the following way:
INVRPT_5023949000004_20080721061325.GB to 5023949000004_MSG_IN_20080721061325.GB
PPRHDR_5017416000006_20080721061424_00000980.GB_m to 5017416000006_MSG_IN_20080721061424_00000980.GB_m
SLSRPT_5023949000004_20080721061317_00000978.GB to 5023949000004_MSG_IN_20080721061317_00000978.GB
Basically I would like to drop first 7 characters from file name. Then insert MSG_IN_ after next 14 characters and leave rest of file name as it is.
I would like to do this using batch script file.
I have not used scripts before and would appreciate help to achieve this.

I would like to add that number of files and the names in the directory will vary from week to week but same renaming rules will be applied to all of them.

vbscript
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFolder = "c:\test"
Set objFolder = objFSO.GetFolder(strFolder)
For Each strFiles In objFolder.Files
If objFSO.GetExtensionName(strFiles) = "GB" Then
strComponents = Split(strFiles.Name,"_")
strComponents(0)=strComponents(1)
strComponents(1)="MSG_IN"
strFiles.Name = Join(strComponents,"_")
End If
Nextsave the above as script.vbs and on command line:
c:\test> cscript /nologo script.vbs

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |