Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Wednesday, 31 May 2017

VBScript to rename file

There are many VBScript to rename file available online. This script is a simple version that will rename file in a directory removing a specific sub string from a filename

Example if you have filename e.g 

001_US.txt
002_US.txt
003_US.txt

Desired output is (with _US removed)

001.txt
002.txt
003.txt

Change Line 13 to your directory containing the files 
and
Change Sub String in Line 26


Code Snippet 


1:    
2:  ' -------------------------------------------------------'  
3:  ' VBScript to Rename files, remove the last specfic sub string file a filename  
4:  ' example if file names are like 001_US, 002_US, 003_US the sub string "_US" can be removed using this script  
5:  ' NOTE: Its always good to have a backup before hand.  
6:  ' Date : 31 May 2017  
7:  ' Author : Muhammad Nauman Yousuf (nauman_yousuf@yahoo.com)  
8:  ' -------------------------------------------------------'  
9:    
10:    
11:  ' Variable declaration and initialization   
12:   Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")  
13:   Dim sDir : sDir   = "c:\temp\one"  
14:   Dim oFile  
15:    
16:     
17:   'List the orignal Files  
18:   WScript.Echo " --- Orgnal File Directory --- "  
19:   For Each oFile In oFS.GetFolder(sDir).Files  
20:     WScript.Echo oFile.Path  
21:   Next  
22:     
23:   WScript.Echo "----- Rename Operation Started:"  
24:     
25:   For Each oFile In oFS.GetFolder(sDir).Files  
26:            oFile.Name = Replace(oFile.Name, "_US", "")  
27:            WScript.Echo "Renamed : " & oFile.Name  
28:   Next  
29:   WScript.Echo "----- Rename Operation Completed:"  
30:         
31:    
32:   'List the orignal Files  
33:   WScript.Echo " --- Final Directory List --- "  
34:   For Each oFile In oFS.GetFolder(sDir).Files  
35:     WScript.Echo oFile.Path  
36:   Next  


Sample Run







References

http://www.pctools.com/guides/scripting/id/2/?act=reference

http://www.pctools.com/guides/scripting/detail/80/?act=reference 

Tuesday, 14 February 2017

Installing .NET Framework 3.5 on Windows 2012


Installing .NET Framework 3.5 on Windows 2012
Installing .NET Framework is a bit different from the standard way like other Roles or Features are installed.

Following is the command
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:d:\sources\sxs

Command Parameters:
/Online targets the operating system you're running (instead of an offline Windows image).
/Enable-Feature /FeatureName:NetFx3 specifies that you want to enable the .NET Framework 3.5.
/All enables all parent features of the .NET Framework 3.5.
/LimitAccess prevents DISM from contacting Windows Update.
/Source specifies the location of the files needed to restore the feature (example, the D:\sources\sxs directory or a network location using \\ we will be using network location in the example below).

Example