![]() ![]() StdOut.Echo " Warning: All files within the directory """ & _ĬurrentFolder.Path & " " " will be renamed." If Not Confirm( " Continue?") Then Exit Sub If objArgs.Count > 2 then dim path: path = objArgs( 0) ' path dim olds: olds = objArgs( 1) ' string to replace dim news: news = objArgs( 2) ' new string dim ext1: ext1 = " " dim ext2: ext2 = " " if objArgs.Count > 3 then ext1 = objArgs( 3) ' old extension if objArgs.Count > 4 then ext2 = objArgs( 4) ' new extension dim CurrentFolder: Set CurrentFolder = fso.GetFolder(path) ' get the parameter list dim objArgs: Set objArgs = WScript.Arguments Option Explicit Dim StdIn: Set StdIn = WScript.StdInĭim fso: Set fso = CreateObject( " Scripting.FileSystemObject")ĭim FilesRenamed: FilesRenamed = 0 Dim FilesSkipped: FilesSkipped = 0 The command line syntax to run the script is as follows: If the pattern is found, it is replaced by the new string and extension that was provided. It searches for string and extension patterns in each file. This script iterates through all the files found in a particular folder. This allows you to create and alter existing files. This object is used to access a computer's file system. This scripts uses the Scripting.FileSystemObject COM object. I wrote this script to allow me to facilitate the batch renaming of files. ![]() For example, I like to use the extension TAB instead of SQL for table scripts. When I extract tables and stored procedures, I usually create many files which could have a particular pattern and extension that needs to be changed. I usually come across these scenarios when I script out the objects from a database to text files. The files can have a particular string pattern which I would like to remove and/or an extension I want to change. Your network administrator can provide details on the best way to accomplish this.I usually have the need to rename several files located on a particular folder. Move the file “rename_file.asp” to your Web server using the Windows Explorer or a File Transfer Protocol program. ![]() Type two lines of text into Notepad as follows: In the text field with the heading “File name:” type “rename_file.asp” without quotes. Click Notepad’s “File” menu and select the “Save As…” item. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |