The second script is a simple one-line batch file, which I call renloop.bat (as in rename loop). Option Explicit 'Filenames are required If = 0 Then WScript.Echo "> Must provide file name!!! <<<" WScript.Quit End If Dim strFile, strRootFolder, strFilename, strNewFilename, objFSO WScript.Echo "*** SUBDIRECTORY FILE RENAMING ***" WScript.Echo "" strFile = WScript.Arguments(0) WScript.Echo "Processing: " & strFile strRootFolder = Left( WScript.ScriptFullName, InStr( WScript.ScriptFullName, WScript.ScriptName ) - 1) WScript.Echo "Root Folder: " & strRootFolder strFilename = Mid( strFile, InStrRev( strFile, "\" ) + 1 ) WScript.Echo "Filename: " & strFilename strNewFilename = Mid( strFile, Len( strRootFolder ) + 1 ) WScript.Echo "Subfolders: " & strNewFilename strNewFilename = Replace( strNewFilename, "\", "" ) WScript.Echo "New Filename: " & strNewFilename Set objFSO = CreateObject( "Scripting.FileSystemObject" ) objFSO.CopyFile strFile, strFilename WScript.Echo "File copied successfully." objFSO.MoveFile strFilename, strNewFilename WScript.Echo "File renamed successfully!" WScript.Echo "*** PROCESS COMPLETE ***"
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |