Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Bluzzi opened this issue Jan 29, 2024 · 0 comments
Open

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

Bluzzi opened this issue Jan 29, 2024 · 0 comments

Comments

@Bluzzi
Copy link
Owner

Bluzzi commented Jan 29, 2024

# 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, "")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant