Ich will einige Daten von DVD auf Platte kopieren und dabei den Namen gleichmässig ergänzen, also
Code: Select all
1.txt -> 1_test.txt
2.doc -> 2_test.doc
3.pdf -> 3_test.pdf
Muss doch gehen .. ??
Moderators: Hacker, Stefan2, white
Code: Select all
1.txt -> 1_test.txt
2.doc -> 2_test.doc
3.pdf -> 3_test.pdf
Peter wrote: 2019-12-12, 16:40 UTC Ich will einige Daten von DVD auf Platte kopieren und dabei den Namen gleichmässig ergänzen, also
Muss doch gehen .. ??Code: Select all
1.txt -> 1_test.txt 2.doc -> 2_test.doc 3.pdf -> 3_test.pdf
Code: Select all
REM Total Commander VBScript "ForEachSelFileDo - Copy to Target and add text.vbs"
REM by Stefan, 2019-12-13, v0.01
REM
REM Purpose: SELECT FILES in one panel, execute this script to copy to TARGET panel while RENAMING by adding some string
REM NO folders supported! only one or more files from one folder at time.
REM Found at: https://ghisler.ch/board/viewtopic.php?f=2&t=55391&p=364865#p364865
REM Ich will einige Daten von DVD auf Platte kopieren und dabei den Namen gleichmässig ergänzen,...
REM
REM Create a plain text file with VBS extension in TC folder and copy this code in that file.
REM Execute from a Total Commander Button:
REM Command: "%Commander_Path%\ForEachSelFileDo - Copy to target and rename.vbs"
REM Parameter: "%L" "%T" <In Button-Dialog click [Help] button to read more>
REM Start path: <leave empty>
REM Icon: WScript.exe -or- wcmicons.dll
REM Tooltip: Copy to other panel and rename
REM
REM -----------------------------------------------------
REM -----------------------------------------------------
REM SCRIPT BASICS
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSO = CreateObject("WScript.Shell")
IF (WScript.Arguments.Count>0) Then vTCsTemp=WScript.Arguments(0) ELSE WScript.Quit ' The TC temp file due to the "%L" parameter
IF (WScript.Arguments.Count>1) Then vTCsTarg=WScript.Arguments(1) ELSE MsgBox "Params missing" : WScript.Quit ' The Target panel due to the "%T" parameter
REM -----------------------------------------------------
REM -----------------------------------------------------
REM USER SETTINGS
strNamensZusatz= "_VonCDkopiert_(2019-12-13)"
'//IB = InputBox(prompt[, title][, default] ,Xpos,Ypos,HelpFile location, Context in the help file)
strNamensZusatz = InputBox(vTCsTarg &vbLF&vbLF& "and add:", "Copy to", strNamensZusatz)
REM also see below at "strNewName" for the wanted order of name parts
REM -----------------------------------------------------
REM -----------------------------------------------------
REM THE CODE
If (strNamensZusatz = "") Then WScript.Quit
If (strNamensZusatz = "?") Then WSO.run "notepad " & WScript.ScriptFullName,1,false : WScript.Quit
SET strTCTempFile = CreateObject("Scripting.FileSystemObject").OpenTextFile(vTCsTemp, 1)
Do While Not strTCTempFile.AtEndOfStream
strCurrFile = strTCTempFile.ReadLine
strNamensZusatz = replace(strNamensZusatz, ":", "")
strNamensZusatz = replace(strNamensZusatz, "*", "")
strNamensZusatz = replace(strNamensZusatz, "?", "")
strNamensZusatz = replace(strNamensZusatz, chr(34), "")
strNamensZusatz = replace(strNamensZusatz, "<", "")
strNamensZusatz = replace(strNamensZusatz, ">", "")
strNamensZusatz = replace(strNamensZusatz, "|", "")
strNamensZusatz = replace(strNamensZusatz, "\", "")
strNamensZusatz = replace(strNamensZusatz, "/", "")
IF Right(strCurrFile,1) <> "\" THEN '//process File only, no Folder
strBaseName = FSO.GetBaseName(strCurrFile)
strExtensio = FSO.GetExtensionName(strCurrFile)
'//strNewName = replace(strCurrFile,"x","U")
strNewName = strBaseName & strNamensZusatz & "." & strExtensio '//USER SETTINGS: order of name parts
'//MsgBox "DEBUG" &vbLF&vbLF& strcurrfile & vbLF&vbLF& vTCsTarg & "\" & strNewName
bSerializeCopies = TRUE
If(bSerializeCopies) Then
Do While( FSO.FileExists(vTCsTarg & "\" & strNewName) )
iSerial=iSerial+1
strNewName = strBaseName & strNamensZusatz & "_" & iSerial & "." & strExtensio 'USER SETTINGS: order of parts
Loop
End If '(bSerializeCopies)
'FSO.MoveFile source, destination
'FSO.MoveFile strCurrFile, vTCsTarg & "\" & strNewName
'FSO.CopyFile source, destination [, overwrite=true]
FSO.CopyFile strCurrFile, vTCsTarg & "\" & strNewName, false
END IF
LOOP
REM EOF
REM -----------------------------------------------------