Flasher

|
Posted: Fri Oct 26, 2012 00:07 Post subject: |
|
|
Code: | ' Переименовать базовое имя файла/папки под курсором на текст в буфере
' Параметр - %V %d
'=====================================================================
With WScript.Arguments
If .Count = 0 then Wscript.Quit
F = .Item(0)
End With
With CreateObject("WScript.Shell")
P = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1407"
A = .RegRead(P)
If A > 0 Then .RegWrite P, 0, "REG_DWORD"
C = Trim(CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text"))
If A > 0 Then .RegWrite P, A, "REG_DWORD"
End With
If C <> "" Then
If InStr(C, vbLf) > 0 Then C = Left(C, InStr(C, vbCr) - 1)
R C, """", "''" : R C, "|", "-" : R C, ":", " -"
R C, ";", "," : R C, "\", "_" : R C, "/", "_"
With CreateObject("Scripting.FileSystemObject")
PF = .GetParentFolderName(F) & "\" : Const M = 1
If .FolderExists(F) Then
Name = C
Do While .FolderExists(PF & Name)
l = l + 1 : If l < 10^M Then PFx = Right(String(M, "0") & l, M) Else PFx = l
Name = C & " (" & PFx & ")"
Loop : .GetFolder(F).Name = Name
Else
Ext = .GetExtensionName(F) : Name = C & "." & Ext
Do While .FileExists(PF & Name)
l = l + 1 : If l < 10^M Then PFx = Right(String(M, "0") & l, M) Else PFx = l
Name = C & " (" & PFx & ")." & Ext
Loop : .GetFile(F).Name = Name
End If
End With : WScript.Quit
End If : Sub R(N, A, B) : N = Replace(N, A, B) : End Sub |
Last edited by Flasher on Fri Oct 26, 2012 14:35; edited 1 time in total |
|