Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
He's playing a game called IRL. Great graphics, *censored* gameplay.
setlocal enabledelayedexpansionfor /f "delims=" %%A in (*.txt) do ( set oldname=%%A set newname=!oldname:_= ! ren "!oldname!" "!newname!" )
@echo offsetlocal enabledelayedexpansiondir /b the*.txt > _txtfiles.txtfor /f "delims=" %%i in (_txtfiles.txt) do (echo %%iset var=%%iFor /F "delims=" %%a in ('echo %%i ^| sed 's/_/ /g') do set var3=%%aecho var =!var!echo var3 =!var3!ren "!var!" "!var3!"rem ren "!var3!" "!var!")
"'sed' is not recognized as an internal or external command,operable program or batch file."
Suppose they don't want to use your weird sounding program?
I can't figure it out...I'd like to rename a number of files, replacing underscores with a space.For example, I'd like to rename "the_first_file.txt" to "the first file.txt" I thought the following would work, but it didn't:RENAME *_*>* *" "*.*Can anyone help a brother out?
I better fess-up on my newbieness; I know less than you think. For the first proposed solution above (thanks to Helpmeh and Salmon Trout), do I just type it into a DOS emulator, or is it more involved?Keep in mind that I want this to go through a few hundred files and make this change to them all (swap an underscore for a space).Ghostdog, there are no instances of multiple underscores, but I would want them replaced by a single space.I tried to identify the elements of the above solution so as to educate myself.Below is a line-by-line explanation. Is my understanding correct?setlocal enabledelayedexpansion - the activity of the command will be kept to a specified folderfor /f "delims=" %%A in (*.txt) do - 'for' is like an "IF" command, but I don't know what /f does. - I don't get the "delims=" either. - Are the percentage signs are wildcards? - I know that *.txt means 'all text files' set oldname=%%A - does this specify the format of the old name? set newname=!oldname:_= ! - this makes sense (I think), it changes the underscore to a space ren "!oldname!" "!newname!" - this renames the file, with the new (underscoreless) nameThank you for your insight and patience,
Ghostdog, there are no instances of multiple underscores, but I would want them replaced by a single space.
Set objFS = CreateObject("Scripting.FileSystemObject")Set regEx = New RegExp ' Create regular expression.regEx.Global=TruestrFolder = WScript.Arguments.Item(0)strOld = WScript.Arguments.Item(1)strNew = WScript.Arguments.Item(2)regEx.Pattern = strOld&"+"Set objFolder = objFS.GetFolder(strFolder)For Each strFile In objFolder.Files strFileName = strFile.Name If objFS.GetExtensionName(strFileName) = "txt" And InStr(strFileName,strOld)>0 Then strFileName = regEx.Replace(strFileName, strNew) strFile.Name = strFileName End If Next
c:\test> cscript //nologo replace.vbs c:\test _ " "