Hi,
I want to select certain files and drop them to a button in Total Commander's button bar, which in return moves them to a target location without confirmation.
What I have tried so far is, I made a move_files.bat file, I dragged the .bat file to TC's button bar, but the problem is it only moves the first file no matter the .bat code. I got help from Chat GPT but it still doesn't move more files then one. I tried Windows Power Shell, and I got the same result: just one file.
Is there any other way i can accomplish this? Maybe some internal command that I am not aware of?
I tried the cm_MoveFiles from TC but I couldn't make it work - Chat GPT was a pain guiding me to make that possible.
here is my .bat code generated by Chat GPT:
@echo off
setlocal
:: Check if any files were passed as arguments
if "%~1"=="" (
echo No files selected.
exit /b
)
:: Set destination directory
set "destination=C:\0"
:: Loop through each file passed as an argument and move it
:loop
if "%~1"=="" goto endloop
echo Moving "%~1" to "%destination%"
move "%~1" "%destination%"
shift
goto loop
:endloop
endlocal
I am running on Windows 10 if that's important.
Thank you for any suggestion
move files like a drop target
Moderators: Hacker, petermad, Stefan2, white
Re: move files like a drop target
When dropping files onto a button in TC's button bar, TC replaces the parameters of that button with the first file that is dropped there. Try with this very simple script for example:No matter how many files you select and drop onto a button that calls this script, you'll always see only the first one. That's just the way it is.
The only way around that is as follows:
Code: Select all
@echo off
echo %*
pause
The only way around that is as follows:
- Create a button with %L in its parameters field
- Change your script to process the list file passed by TC (%L), e.g. with a for /F loop.
- Select the files and click the button (instead of dropping them onto it)
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Re: move files like a drop target
Thank you very much for your response, Dalai, it works very well !
I finally made it with to work with your help, I was stuck for few days on this and it was really frustrating.
Once again, a big thank you and have a nice day
*************
For anyone who might use this information, here is what I did to make it work:
My .bat file is located here C:\1 and my target folder is this c:\0 [ you need to change this with your location/target, obviously , and in the code you need to change the "targetDir=" with your target]
1. I made a move_file.bat with next code in it:
@echo off
set targetDir="C:\0\"
for /F "usebackq delims=" %%f in ("%~1") do (
move "%%f" %targetDir%
)
2. I drag the move_file.bat in the TC's button bar / right click on it / change / in the Parameters I have: %L
3. optional - I can pick an icon file for this button. / click ok
Back to TC main window / I select the files I want to move / click on the new button to move them
I finally made it with to work with your help, I was stuck for few days on this and it was really frustrating.
Once again, a big thank you and have a nice day
*************
For anyone who might use this information, here is what I did to make it work:
My .bat file is located here C:\1 and my target folder is this c:\0 [ you need to change this with your location/target, obviously , and in the code you need to change the "targetDir=" with your target]
1. I made a move_file.bat with next code in it:
@echo off
set targetDir="C:\0\"
for /F "usebackq delims=" %%f in ("%~1") do (
move "%%f" %targetDir%
)
2. I drag the move_file.bat in the TC's button bar / right click on it / change / in the Parameters I have: %L
3. optional - I can pick an icon file for this button. / click ok
Back to TC main window / I select the files I want to move / click on the new button to move them
Re: move files like a drop target
You could also utilize the cm_RenMov command with parameters. Search the help for "cm_RenMov" for more information.
For example, in its most basic form you could use parameter:
Code: Select all
/GT="C:\0\"
Re: move files like a drop target
@ white - Thank you for your reply, this seems to work also. Up until this day none of my efforts were successful, and now I have more then one option .
Thank you again for taking time to respond.
Thank you again for taking time to respond.