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 

Переименование файлов при перемещении в другую папку

 
Post new topic   Reply to topic    Total Commander Forum Index -> Автоматизация Total Commander printer-friendly view
View previous topic :: View next topic  
Author Message
Lari



Joined: 12 Mar 2007
Posts: 30

Post (Separately) Posted: 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

Back to top
View user's profile Send private message
Batya



Joined: 15 Dec 2004
Posts: 2218
Location: Москва, Россия

Post (Separately) Posted: Mon Aug 06, 2007 14:20    Post subject: Reply with quote

Например, так:
Code:

FSO.GetFile(NewFilePath & "\" & FileName).Name = FSO.GetBaseName(NewFilePath & "\" & FileName) & ".txt"


Хотя, в твоем случае проще для метода MoveFile вторым параметром указывать не просто путь, а путь с новым именем файла.
Back to top
View user's profile Send private message
Lari



Joined: 12 Mar 2007
Posts: 30

Post (Separately) Posted: Mon Aug 13, 2007 21:12    Post subject: Reply with quote

Спасибо
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> Автоматизация Total Commander All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group