
Quote from rcohen on February 23, 2025, 3:56 amI am pulling my hair out trying to figure out how to to filewrite a bat file that contains a pipe.
@echo off ( for /f "tokens=5* delims= " %%i in ('dir "D:\downloads" /AL ^| find "<SYMLINK>"') do @echo D:\downloads\%%i %%j ) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sasNo matter how I set the multi line settings (I tried all three) when setting my variable, it always either truncates at the pipe, or it line breaks at the pipe and the pipe disappears. I replaced the pipe with [#124] and that didn't help. And I'm outta ideas.
Anyone know how this might be possible? Currently I have
SetVar "[ForBat]" "@echo off|(| for /f [#34]tokens=5* delims= [#34] %%i in ('dir [#34]D:\downloads[#34] /AL ^| find [#34]<SYMLINK>[#34]') do @echo D:\downloads\%%i %%j|) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas" FileWrite "[PubDir]lst.bat" "All" "[ForBat]"Thanks in advance ;-0
I am pulling my hair out trying to figure out how to to filewrite a bat file that contains a pipe.
@echo off
(
for /f "tokens=5* delims= " %%i in ('dir "D:\downloads" /AL ^| find "<SYMLINK>"') do @echo D:\downloads\%%i %%j
) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas
No matter how I set the multi line settings (I tried all three) when setting my variable, it always either truncates at the pipe, or it line breaks at the pipe and the pipe disappears. I replaced the pipe with [#124] and that didn't help. And I'm outta ideas.
Anyone know how this might be possible? Currently I have
SetVar "[ForBat]" "@echo off|(| for /f [#34]tokens=5* delims= [#34] %%i in ('dir [#34]D:\downloads[#34] /AL ^| find [#34]<SYMLINK>[#34]') do @echo D:\downloads\%%i %%j|) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas"
FileWrite "[PubDir]lst.bat" "All" "[ForBat]"
Thanks in advance ;-0
Quote from mishem on February 23, 2025, 10:15 amSetVar "[ForBat]" "@echo off[#124]([#124] for /f [#34]tokens=5* delims= [#34] %%i in ('dir [#34]D:\downloads[#34] /AL ^[#124] find [#34]<SYMLINK>[#34]') do @echo D:\downloads\%%i %%j[#124]) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas" FileWrite "[PubDir]lst.bat" "All" "![ForBat]"
SetVar "[ForBat]" "@echo off[#124]([#124] for /f [#34]tokens=5* delims= [#34] %%i in ('dir [#34]D:\downloads[#34] /AL ^[#124] find [#34]<SYMLINK>[#34]') do @echo D:\downloads\%%i %%j[#124]) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas"
FileWrite "[PubDir]lst.bat" "All" "![ForBat]"

Quote from rcohen on February 23, 2025, 8:18 pmThanks @mishem,
But the output is still:
@echo off ( for /f "tokens=5* delims= " %%i in ('dir "D:\downloads" /AL ^ find "<SYMLINK>"') do @echo D:\downloads\%%i %%j ) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sasWhich breaks right aft4er the /AL^
Thanks for giving it shot. Most appreciated.
Thanks @mishem,
But the output is still:
@echo off
(
for /f "tokens=5* delims= " %%i in ('dir "D:\downloads" /AL ^
find "<SYMLINK>"') do @echo D:\downloads\%%i %%j
) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas
Which breaks right aft4er the /AL^
Thanks for giving it shot. Most appreciated.

Quote from Darbdenral on February 23, 2025, 9:01 pm@rcohen, I don't know if this is it or not but maybe this works?
SetVar "[ForBat]" "@echo off[#124]([#124] for /f [#34]tokens=5* delims= [#34] %%i in ('dir [#34]D:\downloads[#34] /AL [#94][#124] find [#34]<SYMLINK>[#34]') do @echo D:\downloads\%%i %%j[#124]) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas" FileWrite "[PubDir]lst.bat" "All" "![ForBat]"which outputted this:
@echo off|(| for /f "tokens=5* delims= " %%i in ('dir "D:\downloads" /AL ^| find "<SYMLINK>"') do @echo D:\downloads\%%i %%j|) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sasBrad
@rcohen, I don't know if this is it or not but maybe this works?
SetVar "[ForBat]" "@echo off[#124]([#124] for /f [#34]tokens=5* delims= [#34] %%i in ('dir [#34]D:\downloads[#34] /AL [#94][#124] find [#34]<SYMLINK>[#34]') do @echo D:\downloads\%%i %%j[#124]) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas"
FileWrite "[PubDir]lst.bat" "All" "![ForBat]"
which outputted this:
@echo off|(| for /f "tokens=5* delims= " %%i in ('dir "D:\downloads" /AL ^| find "<SYMLINK>"') do @echo D:\downloads\%%i %%j|) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas
Brad
Quote from mishem on February 24, 2025, 12:11 am@rcohen
Sorry, I didn't check... I just glanced at it now, everything seems to be in place...
Where it breaks, that's where it needs to be fixed. You can even replace the entire text with special characters. ;)
Maybe I'm looking at the wrong thing? Very bad translation, hard to understand the problem...I'm just doing telepathy. :)
SetVar "[ForBat]" "@echo off[#124]([#124] for /f [#34]tokens=5* delims= [#34] %%i in ('dir [#34]D:\downloads[#34] /AL [#94][#124] find [#34]<SYMLINK>[#34]') do @echo D:\downloads\%%i %%j[#124]) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas" FileWrite "[PubDir]lst.bat" "All" "![ForBat]"
Sorry, I didn't check... I just glanced at it now, everything seems to be in place...
Where it breaks, that's where it needs to be fixed. You can even replace the entire text with special characters. ;)
Maybe I'm looking at the wrong thing? Very bad translation, hard to understand the problem...I'm just doing telepathy. :)
SetVar "[ForBat]" "@echo off[#124]([#124] for /f [#34]tokens=5* delims= [#34] %%i in ('dir [#34]D:\downloads[#34] /AL [#94][#124] find [#34]<SYMLINK>[#34]') do @echo D:\downloads\%%i %%j[#124]) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas"
FileWrite "[PubDir]lst.bat" "All" "![ForBat]"
Quote from mishem on February 24, 2025, 12:13 am@darbdenral
I didn't look at it right away, you have exactly the same answer. One head is good, but one and a half is better. This is my other half. :)
I didn't look at it right away, you have exactly the same answer. One head is good, but one and a half is better. This is my other half. :)

Quote from Darbdenral on February 24, 2025, 12:34 amQuote from mishem on February 24, 2025, 12:13 am@darbdenral
I didn't look at it right away, you have exactly the same answer. One head is good, but one and a half is better. This is my other half. :)
@mishem I couldn't have done it without my other half either ;)
Yes, there is one small character I changed, can you find it ??
I replaced the ^ char with [#94]
Quote from mishem on February 24, 2025, 12:13 amI didn't look at it right away, you have exactly the same answer. One head is good, but one and a half is better. This is my other half. :)
@mishem I couldn't have done it without my other half either ;)
Yes, there is one small character I changed, can you find it ??
I replaced the ^ char with [#94]

Quote from rcohen on February 24, 2025, 6:15 amWow, thanks guys for the help.
I still had to modify a few things, as some of those pipes I discovered were new line indicators, but they didn't work even as [#124]. And so by comparing a working script with the output I was able to discover that three of the [#124]'s had to be changed to [#13][#10]
And so NOW, it works as:
SetVar "[ForBat]" "@echo off[#13][#10]([#13][#10] for /f [#34]tokens=5* delims= [#34] %%i in ('dir [#34]D:\downloads[#34] /AL [#94][#124] find [#34]<SYMLINK>[#34]') do @echo D:\downloads\%%i %%j[#13][#10]) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas"Thanks a ton guys. If it weren't for your help I would have NEVER found this.
Many thanks.
Wow, thanks guys for the help.
I still had to modify a few things, as some of those pipes I discovered were new line indicators, but they didn't work even as [#124]. And so by comparing a working script with the output I was able to discover that three of the [#124]'s had to be changed to [#13][#10]
And so NOW, it works as:
SetVar "[ForBat]" "@echo off[#13][#10]([#13][#10] for /f [#34]tokens=5* delims= [#34] %%i in ('dir [#34]D:\downloads[#34] /AL [#94][#124] find [#34]<SYMLINK>[#34]') do @echo D:\downloads\%%i %%j[#13][#10]) >> D:\NeoBook_Pubs\CloudStudioStation\cleanup.sas"
Thanks a ton guys. If it weren't for your help I would have NEVER found this.
Many thanks.

Quote from rcohen on February 24, 2025, 6:32 amAnd if I can ask you guys (or anyone) if the following reg grab, gets the correct default download folder on your system, I'd sure appreciate that. Wanna be sure this works for everyone and not just me ;-)
RegistryRead "HKEY_CURRENT_USER" "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E467B}" "[SystemDownloadFolder]"Thank you.
And if I can ask you guys (or anyone) if the following reg grab, gets the correct default download folder on your system, I'd sure appreciate that. Wanna be sure this works for everyone and not just me ;-)
RegistryRead "HKEY_CURRENT_USER" "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E467B}" "[SystemDownloadFolder]"
Thank you.
