Skip to content

Command to obtain the list of files in a folder #1

@Bluzzi

Description

@Bluzzi
# Ask for the directory path:
Write-Host "Enter the directory path: "

$directory = Read-Host
$reversedDirectory = $directory -replace "/", "\"

# List of directories and files to ignore:
$ignored = @(".git", "node_modules", ".next", ".vscode")

# Loop over the directory items:
Get-ChildItem $directory -Recurse | ForEach-Object {
  # Check if the item is ignored:
  foreach ($ignore in $ignored) {
    if ($_.FullName -like "*$ignore*") {
      return
    }
  }

  # If the item is not ignored, display it:
  Write-Host $_.FullName.Replace($directory, "").Replace($reversedDirectory, "")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions