How to create a TC button cooperating with batch file

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
dmocha
Junior Member
Junior Member
Posts: 52
Joined: 2013-05-05, 19:09 UTC
Location: Poland

How to create a TC button cooperating with batch file

Post by *dmocha »

Hi,

I would like to have a button to pack the selected files (or directories).
The target 7z file should have the current time and date in its name.
I have a small batch file, but I don't know how to use it in a TC button in such a way that it works on selections.

Probably I have to use the parameter /%S
How?

Code: Select all

@echo off
set y=%date:~6,4%
set m=%date:~3,2%
set d=%date:~0,2%
set hr=%time:~0,2%
if "%hr:~0,1%" == " "  set hr=0%h:~1,1%
set min=%time:~3,2%
set sec=%time:~6,2%
set stamp=%y%.%m%.%d%_%hr%.%min%.%sec%
echo %stamp%
c:\tool\7z_cmd\7za.exe a file_%stamp%.7z source_file
Is it at all possible?
regards
dmocha
User avatar
Dalai
Power Member
Power Member
Posts: 9387
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: How to create a TC button cooperating with batch file

Post by *Dalai »

Take a look at the 7zip help file, section Command line version > Syntax. Search for "list file" and you'll see this example:

Code: Select all

7z a -tzip archive.zip @listfile.txt
You should be able to use that in your script like so:

Code: Select all

c:\tool\7z_cmd\7za.exe a "file_%stamp%.7z" "@%~1"
with a button in TC that uses a list file as parameter to your batch script:

Code: Select all

script.cmd "%UL"
Not sure if 7z[a].exe expects list files with a BOM or not, but I'm sure you can figure that out :), or change the list file charset as explained in 7z help.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
dmocha
Junior Member
Junior Member
Posts: 52
Joined: 2013-05-05, 19:09 UTC
Location: Poland

Re: How to create a TC button cooperating with batch file

Post by *dmocha »

Thanks, it works
regards
dmocha
Post Reply