• 0

easy way to remove prefix to file names?


Question

I have a folder with filenames and they all have the prefix named

DDRM-filename1.doc

DDRM-filename2.doc

DDRM-filename3.doc

DDRM-filename4.doc

There has to be like 50 files and i just would like the DDRM part remove cause its annoying and

i figured there was a easier way then file rename each and every file. Is there a way to scan

a directory and change it with a bat or vbs file?

10 answers to this question

Recommended Posts

  • 0
  generalnewbie said:

I have a folder with filenames and they all have the prefix named

DDRM-filename1.doc

DDRM-filename2.doc

DDRM-filename3.doc

DDRM-filename4.doc

There has to be like 50 files and i just would like the DDRM part remove cause its annoying and

i figured there was a easier way then file rename each and every file. Is there a way to scan

a directory and change it with a bat or vbs file?

You can do this in Windows if you highlight all the files and right click-> rename. You will rename only one file (make sure its the top DDRM-filename1 file you right click) and the other will follow. You might not like the results because it will turn out like:

filename.doc

filename(1).doc

filename(2).doc

filename(3).doc

...

...

...

  • 0

Place this VBS Script in the folder that you want to change the names.

Save As ReName.vbs

  Quote
Const OverwriteExisting = True
 Dim File, Folder, StrF, StrT
 Dim Fso	 : Set Fso = CreateObject("Scripting.FileSystemObject")
'/-> Set The Folder Path
  Set Folder = Fso.GetFolder(Fso.GetParentFolderName(WScript.ScriptFullName))
'/-> Object For Collection
  Set File = Folder.Files 
   For Each StrF In File 
'/-> DDRM-filename1.doc Change This DDRM To Match What You Want To Filter
	If InStr(StrF.Name,"DDRMen 
	 StrT = Replace(StrF.Path, "DDRM-", "")
	 Fso.CopyFile(StrF.Path), (StrT),OverwriteExisting
	 Fso.DeleteFile(StrF.Path),True  
	End If 
   Next
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.