Script to create a text file with the path of the current in

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
msrox
Member
Member
Posts: 101
Joined: 2008-03-14, 00:10 UTC

Script to create a text file with the path of the current in

Post by *msrox »

Is there anyway to have a script in TC so that when e.g. you press [enter] on a file in left panel, a text file is created in c:\ with the absolute path of the executed file in left panel written in it?

Is it possible to do this with Tc scripting, or batch commands (.bat) need to be used?

It would be excellent to make this with TC scripts as I'd like it to be as fast as possible and I think batch file would be slower that the native scripts in TC.

So, this is exactly what I what the scrip to do:
1) create a text file with the path to the Entered file in it
2) I want to be able to use it as internal association handler
thanks
Last edited by msrox on 2015-02-06, 16:01 UTC, edited 2 times in total.
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

First of what do you mean with "enter on a file"? Press [Enter] or enter a folder?
Please describe exactly what you're trying to accomplish.
There is no "event" system in TC but you can query the current path with external scripts or pass it to them.
If you only enter certain predefined paths you could combine that action with a script and put it on a button or in a user command.

Maybe this will suffice:
Create a new Button with
Command:

Code: Select all

%comspec% /c
Parameter:

Code: Select all

echo %P%O.%E >c:\CurrentFile.txt
Check "Run Minimized" and choose an icon.

*Edit: MVV was faster ;)
Last edited by ZoSTeR on 2015-02-06, 15:55 UTC, edited 2 times in total.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

If you only need to write current path to some file when you run some command, try this from e.g. buttonbar:

Code: Select all

Command: cmd.exe
Parameters: /c "echo %P>>"c:\path.log""
msrox
Member
Member
Posts: 101
Joined: 2008-03-14, 00:10 UTC

Post by *msrox »

I meant when I [Enter] on a file. So I'd like to set an internal association so that when I [enter] on a file, a .txt with the path to the file is created.

Thanks MVV - how can I do this with internal association instead of buttonbar?
User avatar
nsp
Power Member
Power Member
Posts: 1953
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

TC does not have any scripting capabilities on it's own !
What do you mean by enter in a file ?

Do you a fixed filename where to store all that is selected ?[/code]
msrox
Member
Member
Posts: 101
Joined: 2008-03-14, 00:10 UTC

Post by *msrox »

sorry for the confusion, I modified my question. thanks
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

If you need to write path to some file to log when you press Enter on it, try internally associating (File - Internal Associations) following bat file with desired extension:

Code: Select all

@echo off
echo %~1>>c:\log.txt
You need to paste path to batch and then "%1" in order to pass path to file to it.

E.g. I saved it as d:\1.bat and added an internal association for *.sss type with command d:\1.bat "%1". Now when I press Enter on any .sss file, batch appends a line to log.
msrox
Member
Member
Posts: 101
Joined: 2008-03-14, 00:10 UTC

Post by *msrox »

Perfect, thank you.
Do you know how I can hide the black console windows?

Should I use vbs instead of bat in order to avoid the console windows?
Can vbs work in TC internal association?
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I think you can try to create a LNK for batch and set minimized show mode in its properties, and then specify path to LNK in an association.
msrox
Member
Member
Posts: 101
Joined: 2008-03-14, 00:10 UTC

Post by *msrox »

So, there is no way to do this (writing the path of the executed file in a text file) with built-in commands of TC in Internal association?
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

That's correct, there is no way using only TC itself.
msrox
Member
Member
Posts: 101
Joined: 2008-03-14, 00:10 UTC

Post by *msrox »

Thanks for your help and answers
Post Reply