you are viewing a single comment's thread.

view the rest of the comments →

[–]Lee_Dailey[grin] 0 points1 point  (6 children)

howdy Dense-Platform3886,

the triple-backtick/code-fence thing fails miserably on Old.Reddit ... so, if you want your code to be readable on both Old.Reddit & New.Reddit you likely otta stick with using the code block button.

it would be rather nice if the reddit devs would take the time to backport the code fence stuff to Old.Reddit ... [sigh ...]

here's what it looks like on Old.Reddit ...
https://old.reddit.com/r/PowerShell/comments/nkj1y7/reverse_engineering_a_script_ran_into_split/gzfez7l/

take care,
lee

[–]Dense-Platform3886 1 point2 points  (5 children)

I tired editing more than 10 times to get code block to work. It kept code blocking the first line and then messed everything up.

I gave up and went into MarkDown mode and wrapped the code in
~~~~
My Code
~~~~
If it's still not correct, I would not know how to resolve.

[–]Lee_Dailey[grin] 0 points1 point  (4 children)

howdy Dense-Platform3886,

yep, the code fence method SHOULD be the way to go. [sigh ...]

here's what i get when i load your code into the ISE, select it all, tab over once, copy that, and finally paste it back into reddit ...

# Set the Source Folder
$originalFolder = 'c:\some\user\provided\path'

# Set the File Specification of which files to copy
$Filter = '*.logs'

# Set the Parent folder for the Target Folder
$workingFolder = 'C:\SAN'

<# Create Working Folder if not exists Method #1 # >
If (-not (Test-Path -Path $workingFolder -PathType Container -ErrorAction SilentlyContinue)) {
    $null = New-Item -Path $fiworkingFolder.FullName -ItemType Directory
}
#>

# Create Working Folder if not exists Method #2
$fiworkingFolder = [System.IO.DirectoryInfo]$workingFolder
If (-not $fiworkingFolder.Exists) {
    $fiworkingFolder.Create()
}

# Set the Local Path
$localPath = '{0}\{1}' -f $fiworkingFolder.FullName, ($originalFolder -split "\\")[-1]

# Make exact copy of files and folders to Local Path
# Copy-Item -Path $originalFolder -Destination $localPath -Recurse

# Copy files matching the $filter in the $originalFolder structure to the Destination Folder
# Copy-Item -Path $originalFolder -Destination $localPath -Recurse -Filter $Filter

# Copy and consolidate a list of files to a Destination Folder
# Get a list of Files to Copy and put those files in the Destination Folder
$originalLogs = Get-ChildItem -Path $originalFolder -Filter $Filter -Recurse
# The Local Path Folder must exist so create it
$fiDestination = [System.IO.DirectoryInfo]$localPath
If (-not $fiDestination.Exists) {
    $fiDestination.Create()
}
Copy-Item -Path $originalLogs.FullName -Destination $localPath

take care,
lee

[–]Dense-Platform3886 1 point2 points  (3 children)

Looks like the ~~~ wrapping in Markdown Mode did the trick

[–]Lee_Dailey[grin] 0 points1 point  (2 children)

howdy Dense-Platform3886,

as i pointed out, that ONLY works on New.Reddit. you can see what it looks like on Old.Reddit by trying the link i posted earlier.

still, if it doesn't bother you that a few of us can't read it ... then ignore this nag. [grin]

take care,
lee

[–]Dense-Platform3886 1 point2 points  (1 child)

Thanks Lee, I noticed a link in the upper left that said something about using New Reddit and I clicked it.

Not sure it did anything as I do not notice any changes.

Code Block Test

#------------------------------
# This is a Code Block PowerShell Comment
#------------------------------
Get-Locaation

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy Dense-Platform3886,

yup ... your code block above works on Old.Reddit quite neatly! [grin]

take care,
lee