Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8088

Профиль | Отправить PM | Цитировать


Цитата kuzmakzrezv1:
переименовать файл имя из буфера обмена »
Скрытый текст
Код: Выделить весь код
Option Explicit

Dim strClipboardContent
Dim strSourceFile
Dim strDestFile


With WScript.CreateObject("Scripting.FileSystemObject")
	strClipboardContent = Trim(WScript.CreateObject("htmlfile").parentWindow.clipboardData.getData("text"))
	strSourceFile       = .GetAbsolutePathName(strClipboardContent)
	
	If .FileExists(strSourceFile) Then
		strDestFile = Trim(InputBox("Enter new file name", "Enter new file name", strSourceFile))
		
		If Len(strDestFile) > 0 Then
			If Not StrComp(strSourceFile, strDestFile, vbTextCompare) = 0 Then
				.MoveFile strSourceFile, strDestFile
			Else
				WScript.Echo "Need new name of file."
				WScript.Quit 3
			End If
		Else
			WScript.Echo "User cancel input."
			WScript.Quit 2
		End If
	Else
		WScript.Echo "Can't determine Clipboard content [" & strClipboardContent & "] as correct name of existing file."
		WScript.Quit 1
	End If
End With

WScript.Quit 0

Цитата kuzmakzrezv1:
создать текстовый файл(txt) имя из буфера обмена »
Скрытый текст
Код: Выделить весь код
Option Explicit

Dim strClipboardContent
Dim strSourceFile


With WScript.CreateObject("Scripting.FileSystemObject")
	strClipboardContent = Trim(WScript.CreateObject("htmlfile").parentWindow.clipboardData.getData("text"))
	
	If StrComp(.GetExtensionName(strClipboardContent), "txt", vbTextCompare) = 0 Then
		strSourceFile = .GetAbsolutePathName(strClipboardContent)
	Else
		strSourceFile = .GetAbsolutePathName(strClipboardContent & ".txt")
	End If
	
	If Not .FileExists(strSourceFile) Then
		With .CreateTextFile(strSourceFile)
			.Close
		End With
	Else
		WScript.Echo "Source file [" & strSourceFile & "] already exists."
		WScript.Quit 1
	End If
End With

WScript.Quit 0

Корректность имён особо не проверяется.
Это сообщение посчитали полезным следующие участники:

Отправлено: 06:28, 10-01-2019 | #2