path from clipboard

English support forum

Moderators: Stefan2, white, sheep, Hacker

Post Reply
overconfidenti
Junior Member
Junior Member
Posts: 3
Joined: 2019-03-06, 15:21 UTC

path from clipboard

Post by *overconfidenti » 2019-03-06, 16:09 UTC

hi all
this is example repetitive stucture folder

server
.......example.1.19
..............example.1.19.zr.1
..............example.1.19.prod.1
.......example.2.19
..............example.2.19.zr.1
..............example.2.19.prod.1
etc.

I download file into example.1.19.zr.1 and when I am in folder example.1.19.zr.1, I click button with this script

for %%* in (.) do set CurrDirName=%%~nx*
cd..
set folder=%cd:~14,30%
md ".......\%folder%\%folder%.prod.%CurrDirName:~-1%"
copy "\.......%folder%\%folder%.zr.%CurrDirName:~-1%\*.pdf" ".......\%folder%\%folder%.prod.%CurrDirName:~-1%"
ren ".......\%folder%\%folder%.prod.%CurrDirName:~-1%\*.pdf" "%folder%.prod.%CurrDirName:~-1%.pdf"
echo | set /p=%folder%|clip

Of course I can modify last line of this script to create correct path but I ask, is it possible to change directory from ......example.1.19\example.1.19.zr.1 to ......example.1.19\example.1.19.prod.1 using one click button and clipboard?

thanks

User avatar
Stefan2
Power Member
Power Member
Posts: 2433
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: path from clipboard

Post by *Stefan2 » 2019-03-06, 17:10 UTC

?

Basically your question is:

you are in TC ........ in folder "D:\rive\path\abcZR.1"
and want to switch to folder "D:\rive\path\abcPROD.1"

by use of a button click?

- take current folder name
- change in string ZR to PROD
- go one level up ..
- enter prod folder


?

overconfidenti
Junior Member
Junior Member
Posts: 3
Joined: 2019-03-06, 15:21 UTC

Re: path from clipboard

Post by *overconfidenti » 2019-03-06, 17:37 UTC

yes
I am in TC in "D:\rive\path\abcZR.1"
and I have button with command line: em_usercmd_prod_form_zr,cm_GoToParent
where em_usercmd_prod_form_zr is script
I need third command to go into "D:\rive\path\abcPROD.1"

I know that I click twice and go there and it's not perfect ;) I though that is possible to use CD command with clipboard in some way, to connect third command with em_usercmd_prod_form_zr,cm_GoToParent, then it will work perfect ;)

thanks

User avatar
nsp
Power Member
Power Member
Posts: 1201
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: path from clipboard

Post by *nsp » 2019-03-07, 08:08 UTC

To change folder inside your script, you can call total commander using %COMMANDER_EXE% if the script is launched from TotalCommander. You can set the full destination folder into a variable like folder_path.

Code: Select all

%COMMANDER_EXE% /O /S /L="%folder_path%" 

User avatar
Stefan2
Power Member
Power Member
Posts: 2433
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: path from clipboard

Post by *Stefan2 » 2019-03-07, 08:38 UTC

overconfidenti wrote:
2019-03-06, 17:37 UTC
yes
I am in TC in "D:\rive\path\abcZR.1"
and I have button with command line: em_usercmd_prod_form_zr,cm_GoToParent
where em_usercmd_prod_form_zr is script
...
I need .. command to go into "D:\rive\path\abcPROD.1"
1. write a script to do the modification of the path string (example see below)
Save script in your TC-folder.

2. create a button to execute that script:
Command: "%Commander_Path%\script.ext"
Parameter: "%P"
(%P causes the source path to be inserted into the command line, including a backslash (\) at the end.)
(press [Help] in button-dialog to read more)

3.) go into one of the folders with "ZR" in name,
click your new button,
current path is taken and provided as argument to the script ("%P") and is in script (%1) modified to PROD,
next nsps' command is used to tell TC to change the path in current panel
(see Help > Configuration and Switches > Command line parameters)

Code: Select all

@ECHO OFF
REM MS-DOS Batch script for TotalCommander
REM Found at: https://ghisler.ch/board/viewtopic.php?p=352442#p352442
REM From "D:\rive\path\abcZR.1"
REM go to "D:\rive\path\abcPROD.1"
ECHO %1
SET in=%~1
SET out=%in:ZR=PROD%
ECHO %out%
%COMMANDER_EXE% /O /S /L="%out%" 
PAUSE


HTH? :D
Of course you can safely remove the ECHO and PAUSE commands.
 

overconfidenti
Junior Member
Junior Member
Posts: 3
Joined: 2019-03-06, 15:21 UTC

Re: path from clipboard

Post by *overconfidenti » 2019-03-07, 14:06 UTC

nsp wrote:
2019-03-07, 08:08 UTC
To change folder inside your script, you can call total commander using %COMMANDER_EXE% if the script is launched from TotalCommander. You can set the full destination folder into a variable like folder_path.

Code: Select all

%COMMANDER_EXE% /O /S /L="%folder_path%" 
I used this solution, its was easier to me, thanks

Stefan2, thank you too but i'm not programmer, ;)

Post Reply