avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • August 17, 2018, 07:17 PM
  • Proudly celebrating 13 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - 4wd [ switch to compact view ]

Pages: [1] 2 3 4 5 6 ... 196next
I think it would, creating RegEx rules to cater for them is easy.

Trying to programmatically create them from the directory names is a little more of a challenge.

Kind of getting there in  PowerShell but i don't have a lot of time available at the moment.

@Craig381: Does the NAS require log on credentials or are they already stored/saved in Windows?

ie. Can you just access the share through Explorer without entering user/password?

Also, define "special characters", is this anything other than what Windows defines as forbidden filename characters, (ie. <>: "/\ |?*) ?

ADDENDUM: Also, you could ask skwire to enhance his File Punter program to accept UNC destinations, it should be able to do what you want after you create the RegEx rules.

Living Room / Re: Do Not Buy a Smartwatch Right Now
« on: August 14, 2018, 11:15 PM »
How's the interface?

The watch or the phone app?

The watch face can be changed, see here for a load of user created versions: Amazfit BIP.
Watch interface is locked until you push the button, then you can swipe left/right through the screens: Status, Activity, Weather, Alarm, Timer, Compass, Settings
Tap on the one you want then you can swipe up/down/left or tap to get further into the respective areas. Swiping right goes back up the menu system, it's actually pretty good.

A long press on the button switches it to activity tracking, (you can set default activity: walking, running, etc or go through the menu to select something else), and it will show a screen saying it's getting a GPS lock, (takes about 2 mins), then you tap OK when it vibrates indicating it has lock - you can skip it if you don't want a track log.
Another long press will pause activity tracking and you can choose to continue or end the tracking.

I can't say much about the attendant apps, Mi Fit and the ones from Amazfit.  Huami fall under the Xiaomi unbrella, hence under the Mi ecosystem, that's why the Mi Fit app.

I use a third party app called Notify & Fitness for Amazfit which provides a lot more functionality.

I guess it all comes down to what your main use is, mine was time, notifications, with the added bonus of being able to log a GPS route when I went walking plus it had/has the best battery life available - I did not want to charge it every 1-7 days.


In the screen above, the down arrow in the bottom right indicates there's more info available, eg. step count, step distance, calories, time taken, etc.  (In the case of the Weather screen, it's a 7 day forecast pulled from,I think, could be AccuWeather, for your location, requires your phone naturally).

The interface I currently have, will probably change it as the steps, calories, and heart rate are all available under the Status screen.


It shows 46% on the battery, the app tells me it was charged on July 31, with an expected discharge date of August 28 - depends a lot on notifications, (I get quite a few through emails, SMS, Viber, etc), using vibration shortens the battery life.
When I first got it and hadn't set up any notifications, I got 35 days from 100%->9% before I decided I couldn't be bothered waiting to see how long it was going to take to go flat.

Speaking of Windscribe, one year deal on BdJ today

Windscribe VPN Unlimited Pro
Safeguard All of Your Online Activity
79% Off
$90 ----> $19

I don't have big time VPN experience but from what I see Windscribe is not the fastest, overall very good though

It's a standard deal they have on StackSocial, 1 year @ $19, they also have lifetime @ $69.

I picked up the lifetime version for ~US$39, (early StackSocial deal), about 18 months ago and it's been great.  They have the same deal every so often, last one was in March this year I think.

Living Room / Re: Do Not Buy a Smartwatch Right Now
« on: August 14, 2018, 10:16 PM »
I now have a AmazFit BIP - GPS, barometer, compass, accelerometer, notifications, heart rate, steps, transflective display, etc ... and a 30+ day battery life.

For ~US$60 I paid, I don't think there's anything comparable with the same features especially the battery life.

Recently got FastestVPN 3 Year Plan in just $20 wow its an amazing offer
You can have it from here:

No, just no.

Quick and dirty:

Code: PowerShell [Select]
  1. Get-ChildItem <SRCE> -Recurse -Directory | % { Get-ChildItem $_.FullName -File | Sort-Object Length -Descending | Select-Object -First 1 | Copy-Item -Destination <DEST> }

Change <SRCE> to the source directory, (eg. Z:\test -- the parent of all the sub-directories), change <DEST> to the destination directory, (eg. K:\output), and it should copy the largest file in every sub-directory of the source to the destination, (directory tree is NOT preserved).

If there's an existing file of the same name it'll just skip copying that file, (ie. nothing gets overwritten).

Code: PowerShell [Select]
  1. Get-ChildItem Z:\test -Recurse -Directory | % { Get-ChildItem $_.FullName -File | Sort-Object Length -Descending | Select-Object -First 1 | Copy-Item -Destination K:\output }

You didn't give the specification for that html: namespace though. (But as it's the only namespace used, for data-extraction it can be filtered out)

Or by installing an updated XML module which will give you Remove-XmlNamespace

Still not convinced it's sufficient information since somewhere there should have been a Namespace declaration I would have thought, he's only giving the information for a record within the file.

Well guys, the data is what I posted in my last post (Plants),
It doesn't even look a teensy bit like this new data you've given just now, are you playing us?

PS: This is not related to the initial data file I wanted to process.

So far:
  • XML,
  • XML with Namespace, (file sizes unknown),

... and counting ...

It's another problem, jumping from one thing to another without getting any one thing completed.

It seems that the recommended way to start a non-elevated command from an elevated session is to use the Task Scheduler:

From here:
Code: PowerShell [Select]
  1. <#
  2.   Run-NonEl.ps1
  3. #>
  5. function Run-NonElevated( [string] $cmd ) {
  6.     $task_name = "Run-NonElevated-$(New-Guid)"
  7.     schtasks /Create /RU $Env:USERNAME /TN $task_name /SC ONCE /ST 00:00 /F /TR $cmd
  8.     schtasks /run /tn $task_name
  9.     schtasks /delete /F /tn $task_name
  10. }
  12. Run-NonElevated "%WINDIR%\System32\cmd.exe /C K:\RunAsTester.exe"

Which gives this from an elevated PowerShell console:
2018-08-13 12_07_45-RunAs Test.png

And the following from an elevated PowerShell console:
C:\Windows\System32\cmd.exe /C K:\RunAsTester.exe
2018-08-13 12_11_07-RunAs Test.png

So it appears to work.

Most want to go the other way, Android -> SD Card, but you can try an automation app like:
Tasker (not free) - has an SD Card mount/unmounted event
Automate (free has IAPs but no ads) - has a storage mounted event

There may be others that have a suitable event which you can use to either execute a command within the app or has a plugin to allow it to control another app, (eg. file manager).

Also, I want to run sequential several regex matches with their own references, one by one and append each result to the output file.
You have to make clear whether the results from the separate queries have any positional relation to each other, or can the queries be run one after the other and the output of the second, third, etc., runs appended to the first regex run?

Or to put it another way:
  • STOP trying to describe what you want to happen, (because you're not very good at it).
  • Provide sufficient sample input data of any kind whether it's real or made up (as long as it represents the real format).
  • Provide an example of the output using the input data that shows what you're trying to achieve.
  • PROVIDE relevant feedback, something you consistently fail to do, (eg. 1, 2, 3, 4, etc, etc, etc).

DO NOT give us separate examples of two disparate data types without showing how they relate to one another, (eg. XMLw <> and CDATA []), within the same file.

Until you can do that we're just running around in circles and it's pointless continuing this thread, as such I'm out of here until the above happens.

They were to get a couple of points across, which were completely missed.

1. His guess as to why the first doesn't work will always be better than whatever we could come up with because we never, ever get enough information/context to make an informed guess/opinion.

2. He doesn't read what has already been given because the answer is in this thread.

PS. Sorry mouser ...  :-\

DC Website Help and Extras / Re: DC on the smallish screen
« on: August 10, 2018, 06:15 AM »
I dont remember how -- and cannot see how to access the mobile site -- I'm good at missing the obvious at times, but I made a good effort here and came up with nothing...

Under the menu of Chrome there's an option Desktop site, uncheck it if it's checked - it should immediately refresh and bring up the mobile version.

If it's not checked, try another browser like Firefox Focus or Puffin and see what it shows, they all show no user panel for me unless I specifically tell them to load the Desktop site.

Living Room / Re: Privacy (collected references)
« on: August 09, 2018, 08:04 PM »
Looks like the Ugandan government  could be in the vanguard when it comes to, uh, privacy...
 ...Uganda orders ISPs to block Ugandans from accessing Pornographic Websites   Nice one!    :Thmbsup:

Except they're 2 or 3 years behind Russia.

Any idea why this does not work?
Get-Content *.xml | Out-String

I have a better idea, you tell us why you think it doesn't work.

gc *.xml -match *regex*
does not work :(

Code: PowerShell [Select]
  1. Get-Help Get-Content

You tell us why it doesn't work.

DC Website Help and Extras / Re: DC on the smallish screen
« on: August 09, 2018, 07:55 PM »
@tomos: What browser are you using?

Have you tried the mobile version of DC, there's no user info panel at all in landscape.


Coding Snacks / Re: Custom WinPE build
« on: August 08, 2018, 10:18 PM »
I guess that could have been taken multiple ways.  I meant I can't find the installer for x86/x64 devices.  The installers for other processors are on that page.

These seem to be the instructions: Flashing with eMMC (for Up Squared, other Intel devices)

Geared towards eMMC flashing but it has links to the image and how to create a USB version, should be able to use the info to get somewhere.

4wd did a fine job of explaining all the special chars / shortcuts ...

Hey now, that's going a bit far ...


Powershell Objects
The Complete Guide to Powershell Punctuation
Powershell Commands
Powershell Syntax

Every piece of script I've put in this thread resulted from one simple search - especially the last piece.

I search Google until I get close enough to the answer I want, it's how I learnt Powershell, (and I'm nowhere near being proficient in it).  If you're not getting what you want you're probably being too specific, change your search parameters, because it's a high probability that someone else has already asked it and most likely had it answered.

I suggest you read the link I posted earlier: How To Ask Questions The Smart Way

[Insert deity] knows I'm guilty of asking stupid questions but at least I try to provide all the information required/asked to help whoever it is that may decide to offer help, whether it be data, required output, the right question, cup of coffee, chocolate filled croissant, new car ... (wait, I draw the line there), etc.

And we still have no idea how your various bits of data file relate to each other.

It is not possible for anyone external to offer a complete solution because the source data cannot be shared.

And there you go, a perfect illustration of the main problem.

Despite asking for raw data several times starting from page 1, (and getting various snippets and interpretations), we find out on page 3 that the data can't be shared.

Any reason why you couldn't have told us this when it was first asked?

Also, what is | % { $_.Matches } | % { $_.Value } >> $outfile exactly?

A Pipe


Object passed through pipe.

A Property of the object.

A Property of the object.

You do know that they have this thing called Google, right?

Let's say I want to extract the numbers in the fields ui_mode etc or each of these three separate records.

Code: PowerShell [Select]
  1. gci *.txt | % { sls $_.Name -Pattern '^.*"ui_mode",(\d+).*$' -a | % { $_.Matches } | % { $_.Groups[1].Value } >> K:\out.txt }


Can anyone tell me please how to find a regex in a file and append it to a file? Also, how to loop that?

That is what the code I originally posted does.

Last, how to find the next regex match in the file?

Add another Select-String line with the next RegEx.

I'm going to give up until we get at least sensible raw data and what the expected output should look like ...

But I cannot make it work for my file. Any hint?

Yeah, as Ath suggested, your XML  contains CDATA so you have to read that separately.


General Software Discussion / Re: Et Tu, CCleaner!
« on: August 06, 2018, 07:10 AM »
Considering it has continued to try and access the net since v5.35, (Sept 2017), despite being told not to, why is this a surprise?

But I do not want to work it with Select-XML because it will limit my learning a lot.

If you are going to work with XML then learn to use the most efficient means available otherwise it isn't learning, (well obviously you'll learn from your mistakes but why be inefficient?).

The same applies to JSON, CSV, etc, etc - learning to use the wrong method to achieve what you want is what cripples you.  To put it simply: Use the right tool for the job.

From the Programmer Humor thread, a very eloquent StackOverflow answer that illustrates what Ath said about regexes above.

Do you have one of these files that is considerably less than 25GB, that contains no proprietary data, that you can 7-Zip, (being plain text with lots of repetition it should compress well), then upload to GDrive or somewhere, and then provide us with a link?

It looks suspiciously like JSON data which PowerShell can handle without using RegEx too much. My bad, wrong type of brackets.

What's the first 10-20 lines of the file?
And the last 20 or so, that'll give us enough, (in theory), to create a small test file.

If it was XML might be able to just use the Select-XML commandlet.

Why is it useless? It's exact representation apart from the fact that are more irrelevant text around.

No, it's your interpretation not the exact data, (raw data), which would show us the structure.

Pages: [1] 2 3 4 5 6 ... 196next