Saved Bookmarks
| 1. |
Solve : Tricky file rename -> using WinXP and Win 2003 server? |
|
Answer» Hello group. Hello group. (2) for /f "delims=" %%F in ('dir /b') do ren "%%F" "%%F.txt" Quote from: BryanRay67 on June 20, 2007, 07:57:13 AM
Code: [Select]Dim theFile Set objArgs = WScript.Arguments Set FSO = CreateObject("Scripting.FileSystemObject") theFile=objArgs(0) If InStr(1,theFile,".") > 0 Then Set objFile = FSO.GetFile(theFile) newString = Replace(theFile,".", "-") objFile.Move(newString & ".txt") End If save as myscript.vbs, type cscript myscript.vbs URNT40.d20061101-t182300 on the command prompt. Works for this file naming format. Quote (2) Thanks for your suggestion. This seems to work with the exception of it ALSO renames my batch file that is in the same folder. Is there a way to have this batch file in a parent folder and only call the rename for the CONTENTS of a specified CHILD folder? Thanks! Bryan method (1) This batch file excludes itself from its operation (thisfile.bat is whatever the batch file is called) for /f "delims=" %%F in ('dir /b ^| find /v "thisfile.bat"') do ren "%%F" "%%F.txt" method (2) place this or the the older batch file in a folder somewhere on your PATH, eg C:\Windows, and call it by name at the command prompt from the directory to be OPERATED upon. Thanks for your outstanding help!!!! Regards, Bryan |
|