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
Lari



PostPosted: Sun Aug 05, 2007 12:42    Post subject: Переименование файлов при перемещении в другую папку Reply with quote

Здравствуйте.

Подскажите пожалуйста как можно с помощью скрипта на VB переименовать файл.

Имеется готовый скрипт, который перемещает файл под курсором в папку с именем расширения файла. Как после перемещение изменить расширение файла на другое?

Code:

If WScript.Arguments.Count = 0 Then
MsgBox "Не указаны параметры!", vbOKOnly + vbError, "Внимание!"
Wscript.Quit
End If

Dim TempFile, FSO, SelFile

Set FSO = CreateObject("Scripting.FileSystemObject")
Set TempFile = FSO.OpenTextFile(WScript.Arguments(0), 1)

Dim FileName, FilePath, DashInName, NewFilePath
Do While Not TempFile.AtEndOfStream
Set SelFile = FSO.GetFile(TempFile.ReadLine)
FileName = FSO.GetExtensionName(SelFile)
FilePath = SelFile.ParentFolder
If WScript.Arguments.Count > 1 Then
NewFilePath = WScript.Arguments(1) & FileName
Else
NewFilePath = FilePath & "\" & FileName
End If
If Not FSO.FolderExists(NewFilePath) Then
FSO.CreateFolder(NewFilePath)
End If
If Not FSO.FileExists(NewFilePath & "\" & FileName) Then
FSO.MoveFile SelFile, NewFilePath & "\"
Else
MsgBox "Уже существует файл " & FileName & " в папке " & NewFilePath, vbOKOnly + vbExclamation, "Внимание!"
End If
Loop
Set TempFile = Nothing
Set FSO = Nothing
Set SelFile = Nothing
Wscript.Quit

View user's profile Send private message


Powered by phpBB © 2001, 2005 phpBB Group