Copying 1 File with Brief View

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
pkr67
Junior Member
Junior Member
Posts: 15
Joined: 2012-07-12, 09:18 UTC

Copying 1 File with Brief View

Post by *pkr67 »

I use Brief view, so I can see size, date and time of the actual file in the bottom of the panel (Status bar). I often want co copy (or archive) the file with date or date and time added to its name (backing up an older version of file), e.g. "Some.txt" to "Some160921.txt". But when the dialog appears, size, date and time in Status bar dissapear, there is only something like '400 k / 500 000 k in 1/22 file(s), 0/6 dir(s). So I have to press ESC, write down the date and time and press (Alt+) F5 again. This is enoying.
This behaviour of TC is logical when I have 2 or more files selected, but with 1 file there should stay size, date and time of this file.
Would it be possible? Maybe only with some key in INI file. It would help me a lot.
Thanks.
Pavel
User avatar
Stefan2
Power Member
Power Member
Posts: 4159
Joined: 2007-09-13, 22:20 UTC
Location: Europa

VBScript: ForEachSelFileDo - Rename with date.vbs

Post by *Stefan2 »

You do that by hand?

Maybe you want to utilize an script:

FROM:
"Some.txt"      21.09.2016 9:18
TO:
"Some160921.txt"

USE:

Code: Select all

'       http://ghisler.ch/board/viewtopic.php?t=45748
'       VBS-Script to use with TotalCommander.
'       _ForEachSelFileDo - Rename with date.vbs
'       Purpose: add an date string to file name.
'                choose between Created, Modified or Current time
'       Usage: create the button, select one-or-more files, click the button, done.
'       
'       TotalCommander Button code:
'       CMD:     "%COMMANDER_PATH%\TOOLs\VBS\ForEachSelFileDo.vbs"
'       PARAM:   "%L"
'       START:
'       ICON:    C:\Windows\System32\WScript.exe,2
'       TOOLTIP: ForEachSelFileDo VBS
'       
'       
' %L will create an temporary file like "C:\Users\myusername\AppData\Local\Temp\CMDB034.tmp" which holds the list of the selected files.

Option Explicit
On Error Resume Next
DIM vsTCtempList, vsFullName, vsDrive, vsPath, vsFile, vsBase, vsExte, vsSize, vsVers, vsCreated, vsAccessed, vsModified, oTextStream, oFile
DIM vsParent, vsGrand, vsTopFld, vsTopFld2, vsFilesCount, vsTarget, vsArgument, vsNewFilename, FSO, WSO, vsTimestring
Const FORREADING = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSO = CreateObject("WScript.Shell")

vsTCtempList = Wscript.arguments.Item(0) ' The TC temp file due to the "%L" parameter
If  FSO.FileExists(vsTCtempList) Then
        '//Just for DEBUGging:
            'MsgBox "Tempfile is: " & vsTCtempList 
            'WSO.run "notepad "     & vsTCtempList

        '//START, loop over all selected files:
        Set oTextStream = FSO.OpenTextFile(vsTCtempList,FORREADING)
        Do Until oTextStream.AtEndOfStream
                vsFullName    = oTextStream.ReadLine
                Set oFile    = FSO.GetFile(vsFullName)
                vsFile        = FSO.GetFileName(oFile)
                vsBase        = FSO.GetBaseName(oFile)
                vsExte        = FSO.GetExtensionName(oFile)
                vsCreated     = oFile.DateCreated
                vsAccessed    = oFile.DateLastAccessed
                vsModified    = oFile.DateLastModified '// on a German PC: 09.07.2009 17:05:40
                
                '//format vsModified to wanted string:
                vsTimestring  = mid( vsModified,9,2) & mid( vsModified,4,2) & mid( vsModified,1,2)
                'vsTimestring is here 090709


                '//develop new file name:
                        '// do not rename twice:
                        DIM viLen, vsCheck
                        vsNewFilename = vsFile
                        viLen   = Len(vsTimestring) '6
                        vsCheck = Right(vsBase, viLen) 'last 6 signs
                        If (vsCheck <> vsTimestring) Then
                            vsNewFilename = vsBase & vsTimestring & "." & vsExte
                            'msgbox vsNewFilename
                        End If
                        '// do not rename twice END

                '// Do your work here: 
                If not (FSO.FileExists(vsNewFilename)) Then
                    'FSO.MoveFile source, destination
                    FSO.MoveFile vsFullName, vsNewFilename
                End If

        Loop
        oTextStream.Close
Else
        MsgBox "Input file  vsTCtempList  not found. Check button parameter and quoting.",,"TC-Script Error - ForEachSelFileDo"
End If

Function TimestampNow()
    DIM N,W,D,T
    N = Now
    W = WeekdayName( Weekday(N), true)
    D = Year(N) & Right("00" & Month(N), 2) & Right("00" & Day(N), 2)
    T = Right("00" & Hour(N), 2) & Right("00" & Minute(N), 2) & Second(N)
    TimestampNow = D & "_" & W & "_" & T
    '//20130620 082202
    '//20130620_Do_083851
End Function 'TimestampNow()


 
pkr67
Junior Member
Junior Member
Posts: 15
Joined: 2012-07-12, 09:18 UTC

Post by *pkr67 »

Thank you,
it works fine - after little correction - date (in Czech PC) is not 09.07.2009 but 9.7.2009.
My code:

Code: Select all

'       http://ghisler.ch/board/viewtopic.php?t=45748
'       VBS-Script to use with TotalCommander.
'       _ForEachSelFileDo - Rename with date.vbs
'       Purpose: add an date string to file name.
'                choose between Created, Modified or Current time
'       Usage: create the button, select one-or-more files, click the button, done.
'       
'       TotalCommander Button code:
'       CMD:     "%COMMANDER_PATH%\TOOLs\VBS\ForEachSelFileDo.vbs"
'       PARAM:   "%L"
'       START:
'       ICON:    C:\Windows\System32\WScript.exe,2
'       TOOLTIP: ForEachSelFileDo VBS
'       
'       
' %L will create an temporary file like "C:\Users\myusername\AppData\Local\Temp\CMDB034.tmp" which holds the list of the selected files.

Option Explicit
On Error Resume Next
DIM vsTCtempList, vsFullName, vsDrive, vsPath, vsFile, vsBase, vsExte, vsSize, vsVers, vsCreated, vsAccessed, vsModified, oTextStream, oFile
DIM vsParent, vsGrand, vsTopFld, vsTopFld2, vsFilesCount, vsTarget, vsArgument, vsNewFilename, FSO, WSO, vsTimestring
Const FORREADING = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSO = CreateObject("WScript.Shell")

vsTCtempList = Wscript.arguments.Item(0) ' The TC temp file due to the "%L" parameter
If  FSO.FileExists(vsTCtempList) Then
        '//Just for DEBUGging:
            'MsgBox "Tempfile is: " & vsTCtempList
            'WSO.run "notepad "     & vsTCtempList

        '//START, loop over all selected files:
        Set oTextStream = FSO.OpenTextFile(vsTCtempList,FORREADING)
        Do Until oTextStream.AtEndOfStream
                vsFullName    = oTextStream.ReadLine
                Set oFile    = FSO.GetFile(vsFullName)
                vsFile        = FSO.GetFileName(oFile)
                vsBase        = FSO.GetBaseName(oFile)
                vsExte        = FSO.GetExtensionName(oFile)
                vsCreated     = oFile.DateCreated
                vsAccessed    = oFile.DateLastAccessed
                vsModified    = oFile.DateLastModified '// on a German PC: 9.7.2016 17:05:40
               
                vsModified = Left (vsModified, InStr (vsModified, " ") - 1) '// 9.7.2016
                vsTimestring = Right (Left ("0" + vsModified, InStr ("0" + vsModified, ".") - 1), 2) '// 09
                vsModified = Mid (vsModified, InStr (vsModified, ".") + 1) '// 7.2016
                vsTimestring = vsTimestring + "." + Right (Left ("0" + vsModified, InStr ("0" + vsModified, ".") - 1), 2) '// '09.07
                vsModified = Mid (vsModified, InStr (vsModified, ".") + 1) '// 2016
                vsTimestring = vsTimestring + "." + Mid (vsModified, 1, 4) '// 09.07.2016
                'MsgBox vsTimestring

                '//format vsModified to wanted string:
                vsTimestring  = mid(vsTimestring,9,2) & mid(vsTimestring,4,2) & mid(vsTimestring,1,2)
                'vsTimestring is here 160709

                '//develop new file name:
                        '// do not rename twice:
                        DIM viLen, vsCheck
                        vsNewFilename = vsFile
                        viLen   = Len(vsTimestring) '6
                        vsCheck = Right(vsBase, viLen) 'last 6 signs
                        If (vsCheck <> vsTimestring) Then
                            vsNewFilename = vsBase & vsTimestring & "." & vsExte
                            'msgbox vsNewFilename
                        End If
                        '// do not rename twice END

                '// Do your work here:
                If not (FSO.FileExists(vsNewFilename)) Then
                    'FSO.MoveFile source, destination
                    'FSO.MoveFile vsFullName, vsNewFilename
                    FSO.CopyFile vsFullName, vsNewFilename
                End If

        Loop
        oTextStream.Close
Else
        MsgBox "Input file  vsTCtempList  not found. Check button parameter and quoting.",,"TC-Script Error - ForEachSelFileDo"
End If

Function TimestampNow()
    DIM N,W,D,T
    N = Now
    W = WeekdayName( Weekday(N), true)
    D = Year(N) & Right("00" & Month(N), 2) & Right("00" & Day(N), 2)
    T = Right("00" & Hour(N), 2) & Right("00" & Minute(N), 2) & Second(N)
    TimestampNow = D & "_" & W & "_" & T
    '//20130620 082202
    '//20130620_Do_083851
End Function 'TimestampNow()
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3864
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Post by *sqa_wizard »

What about Multirename tool with Rename mask

Code: Select all

[N][=tc.writedate.yMD]
#5767 Personal license
User avatar
Stefan2
Power Member
Power Member
Posts: 4159
Joined: 2007-09-13, 22:20 UTC
Location: Europa

MULTIRENAME <saved param's> on selected files

Post by *Stefan2 »

Nothing bad with MRT, but to many steps involved.
The script is just a select & execute approach.


Would be nice to be able to execute
a saved MRT preset on selected files?
Like
CMD: LoadRename BaseToUpper
PARAM: %S



- - - EDIT:

Silly me, that already works

CMD: MULTIRENAME BaseToUpper
PARAM: %S


History.txt wrote:30.01.08 Added:
New internal command with parameters:
MULTIRENAME <saved rename parameters>
opens the multi-rename dialog box with the specified rename parameters.
Giving an invalid name will set all options to the default values.

Code: Select all

TOTALCMD#BAR#DATA
Multirename mrTEST
%s
%Commander_Path%\WCMICONS.DLL
Calling MultiRename with saved settings (mrTest) on %S


-1

:oops: :roll: :D




Now I only need another parameter to just rename without opening the MRT dialog 8)



CMD: multirenameS BaseToUpper
PARAM: %S


.... "S", like Silent.

How about, Christian?
Post Reply