Category Archives: files

Path to files on start menu–Part 2

Last time we had got the file names for most of the files but anything in special folders such as the desktop wasn’t displaying properly. We can fix that 001002003004005006007008009010011012013014015016017018019020021022023024025026027028029 $rd = New-Object -ComObject Shell.ApplicationGet-ChildItem -Path $rd.Namespace(0x8).Self.Path | where {-not $_.PSIsContainer} | foreach { if (Test-Path $_.Fullname){   $name = ($_.Name).Replace(“.lnk”,“”)   $ln = $name.length    $txt = (Select-String -InputObject (Get-Content -Path $_.Fullname ) -Pattern “:\” -SimpleMatch).ToString()   $i = $txt.LastIndexOf(“:\”)   $txt2 = $txt.SubString($i–1)      if ($txt2.Startswith(“C:\Users\”) ) {     $txt2 = $txt2.Remove(9, 22)     $txt2 = $txt2.Replace(“`\`\`\$env:COMPUTERNAME”,“”)     … Continue reading

Posted in files, PowerShell V2 | Leave a comment

Path to files on start menu

I was asked today if it was possible the path to  recent files that are shown on the start menu. I thought it was easy until I started digging into it. The files on the start menu  are .lnk files … Continue reading

Posted in COM, files, PowerShell V2 | Leave a comment

Watching the file system

I picked up a question in the ITKE forums about a script to watch the file system   001002003004005006007008009010011012013014015016 function eventhandler {param ($e) Write-Host “File: $($e.SourceEventArgs.FullPath) has arrived”} $folder = “C:\test”$filter = “*”$fsw = New-Object -TypeName System.IO.FileSystemWatcher `-ArgumentList $folder, $filter$fsw.IncludeSubDirectories = $true $action = {eventhandler $($event)} Register-ObjectEvent -InputObject $fsw -EventName “Created” ` -SourceIdentifier “File System Creation” -Action $action   The event handler function accepts the event as a parameter and … Continue reading

Posted in Events, files, PowerShell V2 | Leave a comment

File splitter update

I said last time that I wanted to make the file splitter function a bit more sophisticated. I would like to be able to wrap the distribution so it goes file 1,2,3,3,2,1,1,2..  etc 001002003004005006007008009010011012013014015016017018019020021022023024025026027028029030031032033034 function split-file {[CmdletBinding()]param (  [string]$file=“data.txt”,  [string[]]$outfiles,  [switch]$wrap)   if (!(Test-Path $file)){throw “File $file … Continue reading

Posted in files, PowerShell V2 | Leave a comment

File splitting

I’ve recently had to do a lot of file splitting e.g. taking lists of names and creating lists of alternate names to give me two files. Every time I have one of these problems I seem to re-write the script.  … Continue reading

Posted in files, PowerShell V2 | 2 Comments