1.

Solve : How to move numeric characters from the start of the filename to the end in DOS?

Answer»

On Win XP SP3 using the MSDOS cmd prompt, is it possible to rename MULTIPLE files (all in same directory folder) with the following criteria:-
all files are street addresses ( ie 11 MickeyMouse Road.doc or .pdf )
I want to rename the files with the numeric PART of the address at the end of the file preceeded by , ie( MickeyMouse Road,11.doc(or.pdf))
If possible i also need to insert 4 characters (LAB_) at the start of the filename
ie LAB_MickeyMouse Road,11.doc (or .pdf)
The numerics can be from 1 to 4 characters long.
Can anyone advise the MSDOS commands to achieve this result? Would be much appreciated. are you the same guy as this?

a vbscript for you. for renaming the files, i leave it to you to read the manual to find out how
Code: [SELECT]Set objFS = CreateObject("Scripting.FileSystemObject")
strFolder = "c:\test"
Set objFolder = objFS.GetFolder(strFolder)
For Each strFile In objFolder.Files
strFileName = strFile.Name
ext = objFS.GetExtensionName(strFileName)
If ext = "pdf" Or ext = "doc" Then
strStreet = objFS.GetBaseName(strFileName)
splitted = Split(strStreet," ")
If IsNumeric(splitted(0)) Then
strname=""
For i=1 To UBound(splitted)
strname = strname & " " & splitted(i)
Next
strname = "LAB_" & Trim(strname) & "," & splitted(0)
WScript.ECHO strname & "." & ext
' Put your rename statement here.... i leave it to you

End If
End If
Next
Well for the second one,

@echo off
for /f "delims=" %%A in (dir /b FOLDER) do ren %%A LAB_%%A

should work...although I am working via DSi, so I can't test it.



Discussion

No Comment Found