Copy only directory
Moderators: Hacker, petermad, Stefan2, white
Copy only directory
I found out, that I quite often need to copy directory from one panel to another, but without anything that's inside (no files, or inner folders). I usually do f7 ctrl-c esc tab f7 ctrl-v combo which is tiring and most obviously is very lame way to do what I need. Any suggestions? Thanks!
Just copy the folder (F5) and where it says "only files of this type" enter .. (two dots) that way it will only copy folder(s) but no files.
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
2hi5
The OP doesn't want to copy subfolders, just the directory itself.
orth0dox
I don't see a way to do this with just with TC. You'll need some kind of script for this. I guess, a simple batch script would do it:
You can then create a button with the script like this:
You can copy the code above and paste it onto TC's button bar to create the button and then adapt it to your needs.
Regards
Dalai
The OP doesn't want to copy subfolders, just the directory itself.
orth0dox
I don't see a way to do this with just with TC. You'll need some kind of script for this. I guess, a simple batch script would do it:
Code: Select all
@echo off
REM %1 = source dir
REM %2 = target dir
set t=%~2%~nx1
echo %~1
echo %~2
echo target: %t%
mkdir "%t%"
Code: Select all
TOTALCMD#BAR#DATA
c:\copy_dir.cmd
%P%N "%T"
shell32.dll,-153
copy_dir
-1
Regards
Dalai
#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
Code: Select all
TOTALCMD#BAR#DATA
%comspec% /c for /F "delims=" %N in
(%F) do md "%T%%N"
%comspec%
create directories in target panel from selected source panel names
1
-1
Regards
Holger
Edit: just for the case that one of the selected names contains non ASCII characters -> VB-Script solution from an old german thread:
http://ghisler.ch/board/viewtopic.php?p=105917#105917
Anyone with a powershell solution?

PowerShell: Create selected folder in other panel
I hear you
Or with PowerShell
Hello orth0dox and welcome to the community!
Create folders in other (Target) panel, with names from selected folders in source panel.
Command: PowerShell -NoProfile
Parameter: [face=timesnewroman](Get-Content '%F') | ForEach{ New-Item """%T$_""" -ItemType directory }[/face]
Icon: powershell
Tooltip: Create selected folders in other panel
Shorter, due to PoSh abbreviations:
[face=timesnewroman](GC '%F')|%%{MD """%T$_"""}[/face]
Ready to copy and paste button:
Note: for TC I have to escape the quotes. And double the %-sign of the "ForEach" alias "%" .
Note: %F and %T are TC parameter. (Edit a button, press F1, read more about)
%F Long file names without path, stored one name per line in a temp file.
%T inserts the current target path.
Note: Get-Content creates already an array of lines,
which the ForEach-Object process one after the other
to create a new folder in target panel (%T) with name from current line ($_) of temp file list (%F)
Note: search the forum for "usercmd.ini" to be able to store this command in that file, so you can also assign a shortcut to that command.
- - -
More?
(GC '%L')|%%{$FN=$_ -replace ':'; MD \"%T$FN\"}
Create selected folders in other panel with all parents of source folder
(GC '%L')|%%{$FN=$_ -replace '.:'; MD \"%T$FN\"}
Create selected folders in other panel with all parents, but without drive part

Or with PowerShell
Hello orth0dox and welcome to the community!
Create folders in other (Target) panel, with names from selected folders in source panel.
Command: PowerShell -NoProfile
Parameter: [face=timesnewroman](Get-Content '%F') | ForEach{ New-Item """%T$_""" -ItemType directory }[/face]
Icon: powershell
Tooltip: Create selected folders in other panel
Shorter, due to PoSh abbreviations:
[face=timesnewroman](GC '%F')|%%{MD """%T$_"""}[/face]
Ready to copy and paste button:
Code: Select all
TOTALCMD#BAR#DATA
PowerShell -NoProfil
(GC '%F')|ForEach{MD \"%T$_\"}
c:\windows\system32\windowspowershell\v1.0\PowerShell.exe
Create selected folders in other panel
-1
Note: for TC I have to escape the quotes. And double the %-sign of the "ForEach" alias "%" .
Note: %F and %T are TC parameter. (Edit a button, press F1, read more about)
%F Long file names without path, stored one name per line in a temp file.
%T inserts the current target path.
Note: Get-Content creates already an array of lines,
which the ForEach-Object process one after the other
to create a new folder in target panel (%T) with name from current line ($_) of temp file list (%F)
Note: search the forum for "usercmd.ini" to be able to store this command in that file, so you can also assign a shortcut to that command.
- - -
More?
(GC '%L')|%%{$FN=$_ -replace ':'; MD \"%T$FN\"}
Create selected folders in other panel with all parents of source folder
(GC '%L')|%%{$FN=$_ -replace '.:'; MD \"%T$FN\"}
Create selected folders in other panel with all parents, but without drive part
Nice
%UF or %WF and it will work also with unicode names:
Regards
Holger

%UF or %WF and it will work also with unicode names:
Code: Select all
TOTALCMD#BAR#DATA
PowerShell -NoProfil
(GC '%WF')|ForEach{MD \"%T$_\"}
PowerShell.exe
Create selected folders in other panel
1
-1
Holger
There is a way to completely hide powershell window:
BTW it is better to avoid double-quoting %T to prevent path parsing (e.g. if dir name contains '$' powershell will treat '$' and word after it as var name and expand it):
Code: Select all
powershell.exe -NonInteractive -WindowStyle Hidden ...
Code: Select all
(GC '%WF') | ForEach { MD ('%T' + $_); }
Even with -NonInteractive -WindowStyle Hidden flags window appears for a short time, but if it runs minimized it doesn't bother me anymore, thx!MVV wrote:There is a way to completely hide powershell window:BTW it is better to avoid double-quoting %T to prevent path parsing (e.g. if dir name contains '$' powershell will treat '$' and word after it as var name and expand it):Code: Select all
powershell.exe -NonInteractive -WindowStyle Hidden ...
Code: Select all
(GC '%WF') | ForEach { MD ('%T' + $_); }
No, that will not happen in our case. Me think, because $_ gets just the currentMVV wrote:BTW it is better to avoid double-quoting %T to prevent path parsing (e.g. if dir name contains '$' powershell will treat '$' and word after it as var name and expand it):Code: Select all
(GC '%WF') | ForEach { MD ('%T' + $_); }
index (line) from the array, and will not expand it afterwards even if it contains a '$'.
But ('%T'+$_) is cool and nice, will keep this to avoid """ and ".
thx
I mean that in some dirs "%T$_" will produce wrong results, e.g. "C:\Users\User\AppData\Local\Temp\$mltwcx\$_" will be expanded to "C:\Users\User\AppData\Local\Temp\\dirname": in double-quoted strings sequences like $mltwcx are expanded to values of variables while single-quoted strings are not parsed for variables.
The only problem with '%T' is that path shouldn't contain apostrophe so it isn't universal too...
The only problem with '%T' is that path shouldn't contain apostrophe so it isn't universal too...
Quoting/Escaping arguments in PowerShell can be a real pain.
After plenty of research I found the command line arguments used here.
So instead of:
you could try
I replaced all -Path with -LiteralPath (where applicable).
But even then I had to use for single square brackets because -LiteralPath is still buggy imho.
After plenty of research I found the command line arguments used here.
So instead of:
Code: Select all
-Command "&{&'C:\PathTo\CreateChecksum.ps1' -listFile '%L'}"
Code: Select all
-Command "&{Your-Code '%L'}"
But even then I had to use
Code: Select all
$folderItem.FullName.ToString().Replace('[','`[').Replace(']','`]')