Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Cannot pipe commands in Powershell #519

Open
aborgeld opened this issue Jan 6, 2020 · 2 comments
Open

Cannot pipe commands in Powershell #519

aborgeld opened this issue Jan 6, 2020 · 2 comments

Comments

@aborgeld
Copy link

aborgeld commented Jan 6, 2020

Hi everyone,

This wonderful tool solves my long path issues. But i have two questions

  1. You have a separate class for Directory and File. Say i have the directory 'Delete' (see code below) but i only want to delete files and folders within the Directory Delete. How can i do this, now it's deleting the whole directory.
  2. It seems that adding powershell via a pipe doesn't work. I want to delete files older then 7 days (week), i've tried this: | Where {$_.lastwritetime -lt (Get-Date).AddDays($daysOld)}

Is there a solution to my questions.

Import-Module -Name AlphaFS.dll'
$path = 'D:\Dir\Delete'
     [Alphaleonis.Win32.Filesystem.Directory]::Delete($path,$TRUE)  

#Or 

$path = 'D:\Dir\Delete'
     [Alphaleonis.Win32.Filesystem.File]::Delete($path,$TRUE)  

@Yomodo
Copy link
Collaborator

Yomodo commented Jan 6, 2020

Check out these examples: https://github.com/alphaleonis/AlphaFS/wiki/PowerShell

@aborgeld
Copy link
Author

aborgeld commented Jan 6, 2020

Thank you @Yomodo, i was busy with enumeration. But a foreach on EnumerateFileSystemEntries would be a good place to start.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants