1.

Solve : to change file name?

Answer»

suppose that i have following file (at leaast 100 files)

01-a.pcl
02-b.pcl
03-c.pcl
04-c.pcl
..........
10-x.pcl

how can i get rid of 01-, 02-,...,10-does the number part have always 2 FIGURES?
vbscript
Code: [Select]SET objFSO = CreateObject("Scripting.FileSystemObject")
strFolder = "c:\test"
Set objFolder = objFSO.GetFolder(strFolder)
For Each file In objFolder.Files
If objFSO.GetExtensionName(file) = "pcl" Then
strNewName = Split(file.Name,"-")
file.Name = strNewName(1)
End If
Next

save as script.vbs and on command line ,
Code: [Select]c:\test> CSCRIPT /nologo script.vbs

if you wish for a batch, use a for loop, delim as "-"
Quote from: Dias de verano on May 18, 2008, 11:10:32 AM

does the number part have always 2 figures?


yes

so

is it possible to do by DOS Command is there a possibility to have two files withe diffrunt prefix and same suffix like that

03-c.pcl
04-c.pcl

so that when u delete the prefix from the name u will have two files with the same name in the same directory and have the same ext which is impossible
if no u can use these dos commands

for /f "tokens=1,2 delims=-" %%i in ('dir /b *.pcl') do rename "%%i-%%j" "%%j1"
for /f "tokens=1,2 delims=." %%i in ('dir /b *.pcl1') do rename "%%i.%%j" "%%i.pcl"

u have to rename the file twice to avoid INFINITE loop



Discussion

No Comment Found