From: PAkerly on 19 Aug 2010 22:41 Hello, How would I rename files with an extension line .pdf.mbin to just .pdf so I want: myfile.pdf.mbin to be: myfile.pdf
From: Pegasus [MVP] on 20 Aug 2010 05:02 "PAkerly" <pakerly(a)gmail.com> wrote in message news:ffcbb4e3-a26f-41e9-91a9-0a4556c338ff(a)l6g2000yqb.googlegroups.com... > Hello, > How would I rename files with an extension line .pdf.mbin to > just .pdf > > so I want: myfile.pdf.mbin to be: myfile.pdf Not really a scripting question . . . ren *.pdf.mbin *.
From: "Dave "Crash" Dummy" on 20 Aug 2010 07:55 PAkerly wrote: > Hello, How would I rename files with an extension line .pdf.mbin to > just .pdf > > so I want: myfile.pdf.mbin to be: myfile.pdf There is no "rename" function in VBScript, but you can perform the action by using the "Move" or "FileMove" methods. The script below will do what you ask. Just replace the example "d:\directory" with the path of interest. ---------------------renamer.vbs------------------------- set fso=CreateObject("Scripting.FileSystemObject") set folder=fso.getFolder("d:\directory") for each file in folder.files if right(file.name,5)=".mbin" then file.move left(file.path, len(file.path)-5) end if next ------------------------------------------------------------- -- Crash Atheism is a matter of faith, too.
From: ekkehard.horner on 20 Aug 2010 09:06 Dave "Crash" Dummy schrieb: [...] > There is no "rename" function in VBScript, but you can perform the > action by using the "Move" or "FileMove" methods. [...] Straight from the VBScript Docs: Name Property (FileSystemObject) Sets or returns the name of a specified file or folder. Read/write. object.Name [= newname] object: Required. Always the name of a File or Folder object.
From: "Dave "Crash" Dummy" on 20 Aug 2010 12:02
ekkehard.horner wrote: > Dave "Crash" Dummy schrieb: [...] >> There is no "rename" function in VBScript, but you can perform the >> action by using the "Move" or "FileMove" methods. > [...] Straight from the VBScript Docs: > > Name Property (FileSystemObject) Sets or returns the name of a > specified file or folder. Read/write. object.Name [= newname] object: > Required. Always the name of a File or Folder object. Yes, that will work in this case. Just replace the line file.move left(file.path, len(file.path)-5) with file.name= left(file.name, len(file.name)-5) I got in the habit of using "file.move" instead of "file.name" when what I wanted to change was the case, not the name or extension. This won't work. file.name= lcase(file.name) This will. file.move file.path, folder.path & "\" & lcase(file.name) -- Crash "Facts are stubborn things, but statistics are more pliable." ~ Laurence J. Peter ~ |