Powershell to unhide all files and copy to nextcloud folder
-
I have a customer that services Bobcat equipment.
Bobcat sends out their service manuals on a USB in a time locked PDF. So they expire after 3 months. So annoying.
To make it even more fun, they mark all of the files hidden and created a wrapped executable that you have to launch to search and find the files.
Anyway, to make the documents available to all of the technicians, I have a shared folder in their Nextcloud instance. Nextcloud though, will not sync hidden files, and I do not want to globally change this behavior, if I even can. Never looked.
So what the user was trained to do was right click the USB and uncheck the hidden checkbox.
Then drag and drop all the files to the Nextcloud folder. The problem is this takes forever to rewrite the permissions.So I came up with this script. It works as is, but I am always open to any ideas for improvement.
# Get Drive Letter # To Do: Make this a required parameter or pop up to user $DrvLtr = "D:\" # Destination path for Bobcat files This is a fixed location $BobcatPath = "$ENV:UserProfile\Nextcloud\Bobcat Manuals" # Let the user know we started Write-Host "Now removing the 'hidden' attribute from all files in the path: $DrvLtr" # Unhide all the things. Get-ChildItem -Path $DrvLtr -Recurse -Force | Where-Object {$_.Attributes -like "*hidden*"} | ForEach-Object {$_.Attributes = $_.Attributes -replace ", Hidden|Hidden,? ?", ""} Write-Host "All files unhidden, now copying to Nextcloud sync folder." Robocopy.exe $DrvLtr $BobcatPath /mir /R:5 /W:5 /Z Write-Host "Bobcat USB file copy complete"
The only thing I thought about was adding a
Write-Host
in the unhide section so the user sees something happening and does not complain about nothing running. -
As a comfort item, I’d say the write-host would be nice. Then they know it’s working
-
-
@JaredBusch said in Powershell to unhide all files and copy to nextcloud folder:
damn, that takes 41 mins to copy that? holy crap
-
@Dashrender said in Powershell to unhide all files and copy to nextcloud folder:
damn, that takes 41 mins to copy that? holy crap
That is just the robocopy time. That does not include the time unhiding the files.
-
-
35+ gigs of files - would be nice if they sprung for USB 3 drives.. and make sure the user is using a USB 3 port
-
@JaredBusch dumb question, but if you disconnected a PC from the internet and changed the time to be prior to the expiration date of the files would you still be able to open them?
Fixed a typo
-
Addendum to my allied comment;
You could add the option to allow either displayed or silent processing. That way they have the option.
-
@DustinB3403 said in Powershell to unhide all files and copy to nextcloud folder:
@JaredBusch dumb question, but if you disconnected a PC from the internet and changed the time to be prior to the expiration date of the files would you still be able to open them?
Probably, but it doesn't matter as there are updates that are needed. SO the files have to be updated.
-
@JaredBusch But why robocopy?
-
@Grey said in Powershell to unhide all files and copy to nextcloud folder:
@JaredBusch But why robocopy?
There's no better more convenient option...
-
@Grey said in Powershell to unhide all files and copy to nextcloud folder:
@JaredBusch But why robocopy?
Because it does at least skip the ones with no changes.
Why get convoluted with Powershell to do the same?
-
@JaredBusch I think you should install WSL with Ubuntu 16.04 to do this with bash. . .
-
@JaredBusch said in Powershell to unhide all files and copy to nextcloud folder:
@Grey said in Powershell to unhide all files and copy to nextcloud folder:
@JaredBusch But why robocopy?
Because it does at least skip the ones with no changes.
Why get convoluted with Powershell to do the same?
Not every system may have Robocopy.
-
@Grey said in Powershell to unhide all files and copy to nextcloud folder:
@JaredBusch said in Powershell to unhide all files and copy to nextcloud folder:
@Grey said in Powershell to unhide all files and copy to nextcloud folder:
@JaredBusch But why robocopy?
Because it does at least skip the ones with no changes.
Why get convoluted with Powershell to do the same?
Not every system may have Robocopy.
it became part of theOS with Windows Vista. So anything running Windows Vista or Higher will have robocopy as a part of the Operating system (as everyone should be using higher than vista at this point.. I mean.. windows 7 is obsolete now.. sooo..)
-
@WrCombs said in Powershell to unhide all files and copy to nextcloud folder:
@Grey said in Powershell to unhide all files and copy to nextcloud folder:
@JaredBusch said in Powershell to unhide all files and copy to nextcloud folder:
@Grey said in Powershell to unhide all files and copy to nextcloud folder:
@JaredBusch But why robocopy?
Because it does at least skip the ones with no changes.
Why get convoluted with Powershell to do the same?
Not every system may have Robocopy.
it became part of theOS with Windows Vista. So anything running Windows Vista or Higher will have robocopy as a part of the Operating system (as everyone should be using higher than vista at this point.. I mean.. windows 7 is obsolete now.. sooo..)
Windows 10 1709 is obsolete too, so really anything not with a support mechanism shouldn't be used. But @JaredBusch might be getting paid stupid amounts of money to support Windows XP / Server 2000