Skip to content

Instantly share code, notes, and snippets.

@avipars
Created December 14, 2022 10:56
Show Gist options
  • Save avipars/52ba8b9a94075b28cc667559808b3b05 to your computer and use it in GitHub Desktop.
Save avipars/52ba8b9a94075b28cc667559808b3b05 to your computer and use it in GitHub Desktop.
powershell script to open all files in a set folder
$path = "C:\Users\whatever\folder"
Invoke-Item $path #open that folder
Set-Location -Path $path
$count = 0
foreach($file in Get-ChildItem $path)
{
Invoke-Item -path $file
$count++
}
Write-Host "Opened $count files"
@avipars
Copy link
Author

avipars commented Nov 19, 2024

# If you want to have more control over the types of files that get opened


$path =  "C:\Users\whatever\folder"
$only_open = "*.svg", "*.jpg", "*.png", ".docx", ".doc", ".txt",".pdf" ; #If empty will search in all file formats
Invoke-Item $path #open that folder

Set-Location -Path $path #set the base location

$count = 0 
foreach($file in Get-ChildItem $path -Include $SearchInFormats -File)
{
    Invoke-Item -path $file
    $count++
} 

Write-Host "Opened $count files"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment