"New folder with selection": move selected files to a new created folder

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
Achiles
Junior Member
Junior Member
Posts: 28
Joined: 2007-02-08, 20:32 UTC
Location: Transylvania

"New folder with selection": move selected files to a new created folder

Post by *Achiles »

Hi, all!

On a mac there is a neat function in Finder, it is called "new folder with selection". You select some files and the command places them into a folder; you just need to type a folder name.

Can something like this be done in TC? Select files, hit a shortcut and the files get moved into a directory with the title selected to type.

Thank you.
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: New folder with selection

Post by *Hacker »

Hi Achiles,
Try selecting some files, pressing F6, typing "foldername\", and hitting Enter. Is that what you need?

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: New folder with selection

Post by *white »

Hacker wrote: 2023-09-08, 11:59 UTC pressing F6
Or Shift+F6 (as long as you are moving files on the same drive)
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: New folder with selection

Post by *petermad »

2Achiles

When you copy/move files with F5/F6 you can just edit the first field for your desired target folder. if the target folder is a subfolder to the current folder you can just enter the folder name without drive and path. if the folder does not exist you have to add a \ to the end of the folder name, then TC will create the folder before copying.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Achiles
Junior Member
Junior Member
Posts: 28
Joined: 2007-02-08, 20:32 UTC
Location: Transylvania

Re: New folder with selection

Post by *Achiles »

petermad wrote: 2023-09-08, 12:12 UTC 2Achiles

When you copy/move files with F5/F6 you can just edit the first field for your desired target folder. if the target folder is a subfolder to the current folder you can just enter the folder name without drive and path. if the folder does not exist you have to add a \ to the end of the folder name, then TC will create the folder before copying.
Wow, that's awesome! Thank you, TC rules.
User avatar
Achiles
Junior Member
Junior Member
Posts: 28
Joined: 2007-02-08, 20:32 UTC
Location: Transylvania

Re: New folder with selection

Post by *Achiles »

thanks 'Hacker' too. For some reason, I didn't understand your reply correctly and my test failed :P
User avatar
DaveCmd
Junior Member
Junior Member
Posts: 15
Joined: 2017-07-18, 15:36 UTC

Re: New folder with selection

Post by *DaveCmd »

I tried the F5 and F6 method, and this accomplishes the task. Thanks for showing us that trick.
Still, to the the original poster's suggestion, it would be nice if this could be done with less clicks and typing.

I really love how, in Total Commander, I can select a file and hit F7 and the new folder proposed name is the file name. That saves steps! If I want to take a bunch of files and put them in a new folder of the root directory this is a bit more task laden, so here is an ease of use suggestion
  1. User select selects one or more files and hits F7.
  2. if one file is selected, the new folder name suggestion is the filename of the single selected file (as normal)
  3. if multiple files are selected, the new folder name suggestion is the filename of the LAST selected file
  4. The New folder (directory) popup window contains a check box option: "Move selected files into new folder".
  5. Checking this box will move the selected files into a new folder named by default as the las selected file, or typed in by the user.
Here is a mock up of the idea:
Image: https://i.ibb.co/sq0xtn9/Total-Cmd-Move-Sel-into-New-Folder-mockup.png
This would be a real time saver and make directory cleanup so fast and easy to do. I hope you consider this suggestion. :D
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: New folder with selection

Post by *petermad »

2DaveCmd

In my Extended Menus (see signature) I use these em_commands for that task:

Code: Select all

[em_moveallnewdir]
cmd=%COMSPEC% /C
param=if not exist "%P" (echo Error) else if not exist "%T" (echo Error else if exist %Y%P%S1\* (echo Error else if exist "%T%O" (echo Error else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WL`) do if not exist "%%n\*" xcopy "%%n" "%T%O\" /H /R /K /Y && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WL`) do if not exist "%%n\*" del "%%n" /F /A
menu=Move marked files to directory in opposite panel with name as file under cursor
button=wcmicons.dll,63
iconic=1

[em_moveallnewdir2]
cmd=%COMSPEC% /C
param=if not exist "%P" (echo Error) else if not exist "%T" (echo Error) else if exist %Y%P%S1\* (echo Error) else if exist %T%N (echo Error) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WL`) do if not exist "%%n\*" xcopy "%%n" "%T%O.%E\" /H /R /K /Y && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WL`) do if not exist "%%n\*" del "%%n" /F /A
menu=Move marked files to directory in opposite panel with name + extension as file under cursor
button=wcmicons.dll,63
iconic=11

You can also do it with a multi-command:

Code: Select all

[em_moveallnewdir]
cmd=cm_MkDirOther,cm_Return,cm_FocusTrg,cm_MoveOnly
menu=Move marked files to directory in opposite panel with name as file under cursor
button=wcmicons.dll,63

If you want the moving process to start automatically you can use:

Code: Select all

[em_moveallnewdir]
cmd=cm_MkDirOther,cm_Return,cm_FocusTrg,cm_RenMov /G
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
DaveCmd
Junior Member
Junior Member
Posts: 15
Joined: 2017-07-18, 15:36 UTC

Re: "New folder with selection": move selected files to a new created folder

Post by *DaveCmd »

2petermad
First off, I wanted to say that I was blown away by your Extended Menus plugin. That is a tremendous amount of work, and I will explore it more, thank you.

I was trying some of your code as a button and I am stumped. This is what I have so far:

Code: Select all

[em_moveallnewdir]
cm_MkDir,cm_Return,cm_MoveOnly
So I select my files, it prompts me to name the folder, defaulting to the name of the file under my cursor (perfect!), but it does not move the files into the directory. It created the folder in the same panel, but the files are not moved and the new folder is empty.

I was attempting to adapt your code so that the files I selected would move into the new folder in the SAME panel. I don't want the new folder and files to be in the other panel. Does this make sense? I would be grateful for any help. :D
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: "New folder with selection": move selected files to a new created folder

Post by *petermad »

2DaveCmd
I was attempting to adapt your code so that the files I selected would move into the new folder in the SAME panel.

For that you need two em_commands:

Code: Select all

[em_moveallnewdir0]
cmd=cm_RenMov
param=/GT="%Q%N\"

[em_moveallnewdir]
cmd=cm_MkDir,em_moveallnewdir0
Use the second one (em_moveallnewdir) for the execution.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
DaveCmd
Junior Member
Junior Member
Posts: 15
Joined: 2017-07-18, 15:36 UTC

Re: "New folder with selection": move selected files to a new created folder

Post by *DaveCmd »

2petermad
Oh Splendid! It works perfectly, thanks! I never thought it needed two em_ commands. :D :D

One least question: I made a button with your original code to move the new folder to the opposite panel. It works fine, but the after executing the code, Total Commander's target panel is up a directory level, inside the newly created and moved folder. Is it possible to get the target panel to move back to (or remain in) the parent directory?

Here is the code I tried but it moves to the parent folder of the source panel instead:

Code: Select all

[em_moveallnewdirtarg]
cm_MkDirOther,cm_Return,cm_FocusTrg,cm_RenMov /G,cm_FocusTrg,cm_GoToPreviousDir
I tried many different things including attempts with cm_FocusSrc and even splitting the commands, but to no avail. Any suggestions?
Thank you for your patience :oops:
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: "New folder with selection": move selected files to a new created folder

Post by *petermad »

2DaveCmd
Is it possible to get the target panel to move back to (or remain in) the parent directory?
You can either add cm_Wait 100 to yiour command:

Code: Select all

[em_moveallnewdirtarg]
cm_MkDirOther,cm_Return,cm_FocusTrg,cm_RenMov /G,cm_Wait 100,cm_FocusTrg,cm_GoToPreviousDir
But it is unpredictable how long a wait you need, it can be influenced by processor speed, and numver of files to be moved.

It would be better to use another set of commands:

Code: Select all

[em_moveallnewdirother0]
cmd=cm_RenMov
param=/GT="%Q%T%O\"

[em_moveallnewdirother]
cmd=cm_MkDirOther,cm_FocusTrg,em_moveallnewdirother0
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
DaveCmd
Junior Member
Junior Member
Posts: 15
Joined: 2017-07-18, 15:36 UTC

Re: "New folder with selection": move selected files to a new created folder

Post by *DaveCmd »

2petermad
Okay, I will give this a try, thank you.
I discovered a list of the special parameters:
https://www.ghisler.ch/wiki/index.php?title=Buttonbar#Special_parameters:
I do not see %Q listed anywhere.
What does %Q do?
Is this the correct list of parameters, or is there another list?
User avatar
beb
Senior Member
Senior Member
Posts: 435
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: "New folder with selection": move selected files to a new created folder

Post by *beb »

2DaveCmd
Total Commander Help [F1] > [Index tab] >
> Change start menu - Parameters
or
> User defined menu - Parameters
%Q Turn off automatic quotation marks around certain parameters like %P%N when the name contains a space.
The user will then have to place them by himself.
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: "New folder with selection": move selected files to a new created folder

Post by *petermad »

2DaveCmd
What does %Q do?
See beb's answer. It would not work for file and direrctory names with spaces without the %Q, because quotation marks are mandatory for the /T= parameter for cm_RenMov, so without %Q, paths with spaces would get double quoted.

Run:

Code: Select all

hh.exe %COMMANDER_PATH%\TOTALCMD.CHM::dlg_choosecommand.htm
to see the Help for cm_commands with parameters

Run:

Code: Select all

hh.exe %COMMANDER_PATH%\TOTALCMD.CHM::dlg_configbuttonbar.htm
to see the Help for commands AND parameters (%P, %N, %Q etc.) for buttons and user commands
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Post Reply