Sometimes I wanted to remove underscores in file name and replace it with space. For example I would like to see the filename as 'Sharifah Aini - Suasana Hari Raya.mp3' instead of 'Sharifah_Aini_-_Suasana_Hari_Raya.mp3'. I often have this kind of files when I download mp3s on the internet. I know this maybe so simple because you can just select the file in Windows Explorer, Press F2 and manually rename the file. But for a collections of files in a folder, this may be a boring repetitive task that I'll hate to do.
So, as a damn lazy coder , I've wrote a short Visual Basic Script to automatically do the task with only one simple command. I think this VBScript maybe useful for you too. So, I would like to share my VBScript to replace underscores in filename with spaces for all files within a folder. Here's the script...
'========================================================
' VBScript to replace underscore in file name with space
' for each files in a folder
' Written by DaKc of http://easyybloger.blogspot.com
'========================================================
Dim sName
Dim fso
Dim fo1
' create the filesystem object
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
' get current folder
Set fol = fso.GetFolder(".")
' go thru each files in the folder
For Each fil In fol.Files
' check if the file name contains underscore
If InStr(1, fil.Name, "_") <> 0 Then
' replace underscore with space
sName = Replace(fil.Name, "_", " ")
' rename the file
fil.Name = sName
End If
Next
' echo the job is completed
WScript.Echo "Completed!"
To use the script, you just need to copy this scripts to a text file and then name the textfile with 'rmus.vbs' or any other name you like with '.vbs' extension which is for vbscript.
There is lots of ways to use the script. One of them is, copy the .vbs file to the folder you want the task to be done and then double click the .vbs file in that folder. When the script is done, it will prompt you with a message box which says 'Completed!'. I'll post the other ways to run this kind of scripts later. Feel free to bookmark or subscribe this blog to automatically get updates on this blog.
If you like this code, feel free to use it and if you like to spread it on the net, please gimme a link to this page. I would love to hear your comments too!
VBScript to Replace Underscores in Filename with Spaces for All Files in a Folder
Related Posts:
VBScript to Replace Underscores in Filename with Spaces for All Files in a FolderSometimes I wanted to remove underscores in file name and replace it with space. For example I would like to see the filename as 'Sharifah Aini - Suas… Read More
0 comments:
Post a Comment