Add files to ignore list with hotkey
Moderators: white, Hacker, petermad, Stefan2
-
- Junior Member
- Posts: 8
- Joined: 2015-08-19, 10:53 UTC
Add files to ignore list with hotkey
Hey I would like to map a hotkey which enables me to quickly add selected files to the ignore list. I've not found anything in the command list that would seem to do that. Is it possible?
Me think, yes, by a script
Lets think about:
--- selected files > TC param "%F" (Long file names without path, e.g. Long name.exe)
--- ignore list > "%Commander_Path%\tcignore.txt"
--- pseudo script > for each line in %F, echo line to tcignore.txt
--- Script > called from a user defined command in "%Commander_Path%\usercmd.ini"
[em_AddToIgnorelist]
cmd="path\to\script.cmd"
param="%F"
(or whole script is in usercmd.ini)
[em_AddToIgnorelist]
cmd=For /f eachline in ("%F") Do @echo line >> "%Commander_Path%\tcignore.txt"
--- A hotkey is assigned to that usercmd "em_AddToIgnorelist"
If you can't do that by yourself, we will provide you the solution.
Lets think about:
--- selected files > TC param "%F" (Long file names without path, e.g. Long name.exe)
--- ignore list > "%Commander_Path%\tcignore.txt"
--- pseudo script > for each line in %F, echo line to tcignore.txt
--- Script > called from a user defined command in "%Commander_Path%\usercmd.ini"
[em_AddToIgnorelist]
cmd="path\to\script.cmd"
param="%F"
(or whole script is in usercmd.ini)
[em_AddToIgnorelist]
cmd=For /f eachline in ("%F") Do @echo line >> "%Commander_Path%\tcignore.txt"
--- A hotkey is assigned to that usercmd "em_AddToIgnorelist"
If you can't do that by yourself, we will provide you the solution.
-
- Junior Member
- Posts: 8
- Joined: 2015-08-19, 10:53 UTC
I thought I had it figured out, but I get "File not found" each time I try it. Not sure which file is meant there, but this is what I've done so far:
Tried with %Commander_Path% but the configuration files are located elsewhere so changed that to %$APPDATA%\GHISLER\
The script in usercmd.ini:
[em_AddToIgnorelist]
cmd=FOR /F "tokens=*" %%G IN (%F) DO ECHO %%G >> "%$APPDATA%\GHISLER\tcignore.txt"
And a mapped hotkey to it in wincmd.ini:
[Shortcuts]
A+DEL=em_AddToIgnorelist
I must be doing something wrong. That command is supposed to be like batch-script, right?
Tried with %Commander_Path% but the configuration files are located elsewhere so changed that to %$APPDATA%\GHISLER\
The script in usercmd.ini:
[em_AddToIgnorelist]
cmd=FOR /F "tokens=*" %%G IN (%F) DO ECHO %%G >> "%$APPDATA%\GHISLER\tcignore.txt"
And a mapped hotkey to it in wincmd.ini:
[Shortcuts]
A+DEL=em_AddToIgnorelist
I must be doing something wrong. That command is supposed to be like batch-script, right?
Good start, woutermense!
Yes, that is like DOS batch stuff.
First idea (nothing tested yet, have other things to do )
is to quote the "%F" part if you have space in your user name.
For that %F, %L and so on variables a temporarily file is created in your user temp folder (%temp%)
Perhaps I am wrong and you have to use cmd.exe too:
cmd=cmd /c
param=FOR /F "tokens=*" %%G IN ("%F") DO ECHO %%G >> "%$APPDATA%\GHISLER\tcignore.txt"
Yes, that is like DOS batch stuff.
First idea (nothing tested yet, have other things to do )
is to quote the "%F" part if you have space in your user name.
For that %F, %L and so on variables a temporarily file is created in your user temp folder (%temp%)
Perhaps I am wrong and you have to use cmd.exe too:
cmd=cmd /c
param=FOR /F "tokens=*" %%G IN ("%F") DO ECHO %%G >> "%$APPDATA%\GHISLER\tcignore.txt"
-
- Junior Member
- Posts: 8
- Joined: 2015-08-19, 10:53 UTC
I got the script correct to update the ignore list file. It will put any selection of files and folders in the list. The changes are effective after I restart TCMD. Think there's any way to make it read in the updated list immediately?
Anyway:
I used the cmd.exe way and to see what's going on I put &&PAUSE at the end.
"%F" put the filename of the generated temp file in the ignore list. So I kept just %F
Spaces are a thing in batch, so I got added spaces in the ignore list. I removed unnecessary spaces from the command to prevent it.
Final command:
[em_AddToIgnorelist]
cmd=cmd /c
param=FOR /F "tokens=*" %%G IN (%F) DO ECHO %%G>>"%%APPDATA%%\GHISLER\tcignore.txt"&&PAUSE
&&PAUSE should be removed after testing of course.
Anyway:
I used the cmd.exe way and to see what's going on I put &&PAUSE at the end.
"%F" put the filename of the generated temp file in the ignore list. So I kept just %F
Spaces are a thing in batch, so I got added spaces in the ignore list. I removed unnecessary spaces from the command to prevent it.
Final command:
[em_AddToIgnorelist]
cmd=cmd /c
param=FOR /F "tokens=*" %%G IN (%F) DO ECHO %%G>>"%%APPDATA%%\GHISLER\tcignore.txt"&&PAUSE
&&PAUSE should be removed after testing of course.
You can switch ignore list state twice in order to reread list file. Using TCFS2 you can use switch_ignore_list command (it will switch its state itself), or you can send cm_SwitchIgnoreList (2922) command to TC with other tools like TCMC.
It may have sense BTW to check if items to be added are already exist in list...
It may have sense BTW to check if items to be added are already exist in list...
PowerShell: Remove Duplicate Rows Lines From A Text file
Just for the record (and to find later again)MVV wrote:Y...
It may have sense BTW to check if items to be added are already exist in list...
Have a file "RemoveDupsLines.ps1"
Code: Select all
#http://www.secretgeek.net/ps_duplicates
#Remove Duplicate Rows From A Text File Using Powershell... unsorted file, where order is important
#Call from DOS batch: PowerShell .\RemoveDupsLines.ps1 """File to clean up.txt"""
$MyFile=$args[0];$hash=@{};(gc $MyFile)|%{if($hash.$_ -eq $null){$_};$hash.$_ =1} | Out-File -Encoding ASCII $MyFile
And add a line to above mentioned DOS Batch:
[em_AddToIgnorelist]
cmd="path\to\script.cmd"
param="%F"
Code: Select all
@ECHO OFF
FOR /F "tokens=*" %%G IN (' TYPE "%1" ') DO ECHO %%G>>"%%APPDATA%%\GHISLER\tcignore.txt"
PowerShell "%Commander_Path%\RemoveDupsLines.ps1 """%%APPDATA%%\GHISLER\tcignore.txt"""
If interested, please test if that works (works for me in my tests)