Thanks.
S.
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun07/hey0601.mspx
Santander
Here's a modified version, I entered the zip and jpg extension names
for you. (See - (strExtension = Replace(strExtension, "zip", "jpg"))
You just need to change the path variable (line 2) to point to the
folder you want to make the changes in. I also added a confirmation if
that's what you were talking about.
Jeff
strComputer = "."
Path = "C:\testfolder"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Set colFiles = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='"& Path &"'} Where " _
& "ResultClass = CIM_DataFile")
Msgbx = MsgBox ("You're about to rename all the files with zip
extensions to jpg in" & vbCrLf & _
"" & Path & vbCrLf & _
"" & vbCrLf & _
"Do you wish to continue?", 4 + 48, "Rename File Extensions")
If Msgbx = 6 Then
For Each objFile In colFiles
strExtension = objFile.Extension
strExtension = Replace(strExtension, "zip", "jpg")
strNewName = objFile.Drive & objFile.Path & objFile.FileName & "."
& strExtension
errResult = objFile.Rename(strNewName)
Next
WScript.Echo "Finished!"
Else
WScript.quit()
End If
> Jeff
WScript.Echo "Finished!"
Else
WScript.quit()
End If
----------------
Hi,
I tried, script twice showed error:
Line: 4
Char: 67
Error: Unterminated string constant
Code: 800A0409
this line originally was breaked in word \root\cimv2" so I deleted space
and it to make it one line.
Second error was same in another place where is message box long text.
Now it show another error: Line: 21; Char:1; Error: Expected Statement;
Code: 800A0400
it is text "& strExtension"
thanks.
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Msgbx = MsgBox ("You're about to rename all the files with zip
extensions to jpg in" & vbCrLf & _
I need to on double click on file named file.bak name and extension of
file change to
fila.bak.dwg
i try to change this script myself, but didnt suceed
thanks Igor
strComputer = "."
Path = "C:\testfolder"
StartExt = "bak"
EndExt = "bak.dwg"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & _
"\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='"& Path &"'} Where " _
& "ResultClass = CIM_DataFile")
Msgbx = MsgBox ("You're about to rename all the files with " _
& StartExt & " extensions to " & EndExt & " in" & vbCrLf & _
"" & Path & vbCrLf & _
"" & vbCrLf & _
"Do you wish to continue?", 4 + 48, "Rename File Extensions")
If Msgbx = 6 Then
For Each objFile In colFiles
strExtension = objFile.Extension
strExtension = Replace(strExtension, StartExt, EndExt)
strNewName = objFile.Drive & objFile.Path & objFile.FileName & _
:) sorry if i bother you
i am not a programmer but if I can get path and name of file i
doubleclick
a can with
strNewName = objFile.Drive & objFile.Path & objFile.FileName &
objFile.Extension & ".dwg"
change it...
hmmmmm
----------
Still have problem: show error:
Line:4, Char:1, Error: "File name or class name not found during automation
operation 'GetObject'
Line 4 is
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Thanks.
Jeff
The script will then change any files with extension types you specify
within the folder you specify.
Jeff
Igor
(Show error: Line:4, Char:1, Error: "File name or class name not found
during automation operation 'GetObject'
Line 4 is
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
thanks,
Santander
so, probably WinXP WSH have a class, that missing in Win98?
S.
Look at the download details for WMI for W98:
File Name: wmi9x.exe
Version: 1.5
Date Published: 2/11/2000
I think it does NOT have a lot of stuff that was built into the newer WMIs
for newer OSs.
-Paul Randall
>> so, probably WinXP WSH have a class, that missing in Win98?
>
> Look at the download details for WMI for W98:
> File Name: wmi9x.exe
> Version: 1.5
> Date Published: 2/11/2000
>
> I think it does NOT have a lot of stuff that was built into the newer WMIs
> for newer OSs.
>
> -Paul Randall
---------------
yes, that's right. Perhaps there is universal way that works on both
systems, though.
Thanks.
I am in need of a similar script, but all the files currently have no
extension. I just need to add ".pdf" to about 900 files in the same folder.
What would it take to modify this script to work for that?
Thanks!
Is this a one-shot deal? If so, try opening a command console an
navigating tothe folder. Then issue the following statement at the
prompt:
ren *. *.pdf
Or, this can be done under script control ...
sPathspec = "D:\your\target\folder"
with createobject("wscript.shell")
.currentdirectory = sPathspec
.run "%comspec% /c ren *. *.pdf", 0, true
end with
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
"Tom Lavedas" wrote:
Oh wow, that was easy! The "ren" command worked great. I was trying to
make it much more complicated than it should have been...
Thanks!!
Yes, the command console is actually still useful for some things.
Just an aside: Have you ever wanted a listing of the contents of a
certain folder to add to a document. Well, the GUI cannot provide an
electronically alterable listing of a folders contents (only a
picture), while it is a piece of cake to get one at the command
console ...
dir /o /a-d *.* > listing.txt
Tom