Help: How to make a list of files %UF with quotes in TC?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
PiotrMPPL
Junior Member
Junior Member
Posts: 59
Joined: 2018-10-26, 07:04 UTC

Help: How to make a list of files %UF with quotes in TC?

Post by *PiotrMPPL »

Hi

How to make a list of files %UF with quotes in TC?

ex

"Text.txt"
"Folder\"

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

Re: Help: How to make a list of files %UF with quotes in TC?

Post by *Stefan2 »

 
PiotrMPPL wrote: 2023-07-14, 07:09 UTC Hi
How to make a list of files %UF with quotes in TC?
ex
"Text.txt"
"Folder\"

Please help



One way for example:

(copy&paste button code)

Code: Select all

TOTALCMD#BAR#DATA
powershell -noexit
Get-Content '%UF' | ForEach{ ""[char]34""+$_+""[char]34"" } | Out-File "$env:Commander_Path\_FileList.txt"
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
PS TEST ForEach in "%UF" (selected files and folders)


-1




Explanation
- TC create a temp file with all selected files and folders (%L, %F, %Wx , %Ux)
----- right click an button to edit it, in that dialog press the [Help]-button for more...
- We read that temp file (Get-Content '%UF') and loop over it (ForEach-Object{ $_})
- For each line from that temp file ($_) we get the line and add quotes around
---- tricky " " [char]34 " " because TC eats the outer quotes and so does the posh interpreter
---- normally we use three quotes " " " or \" to get one single quote, but here we want also to get an quote in the output :|
- The result we put out to a new file in the TC folder or to clipboard if you want:
Out-File "$env:Commander_Path\_FileList.txt"
Out-File "$env:TEMP\_FileList2.txt"
Out-File "C:\TEMP\_FileList3.txt"
Set-Clipboard (needs PSv5 or newer)




 
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: Help: How to make a list of files %UF with quotes in TC?

Post by *Fla$her »

2PiotrMPPL
Do you need a list in a file or clipboard?
Overquoting is evil! 👎
Post Reply