Total Commander Forum Index Total Commander
Форум поддержки пользователей Total Commander
Сайты: Все о Total Commander | Totalcmd.net | Ghisler.com | RU.TCKB
 
 RulesRules   SearchSearch   FAQFAQ   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single Post  Topic: Кнопка для вставки текста из буфера с заменой символов 
Author Message
Flasher



PostPosted: Fri Oct 26, 2012 00:07    Post subject: Reply with quote

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
View user's profile Send private message


Powered by phpBB © 2001, 2005 phpBB Group