- 1 year ago
Powershell command to fetch all file path for all desired files extensions
In PowerShell, you can use the Get-ChildItem
cmdlet to fetch all file paths for specific file extensions. Here's an example command that retrieves the paths of all files with the extensions .txt
, .csv
, and .xlsx
in a given directory:
powershellGet-ChildItem -Path "C:\Path\To\Directory" -Recurse -Include *.txt, *.csv, *.xlsx | ForEach-Object { $_.FullName }
Replace "C:\Path\To\Directory"
with the path to the directory where you want to search for files. The -Recurse
parameter ensures that files are searched recursively in subdirectories. The -Include
parameter specifies the desired file extensions (*.txt
, *.csv
, and *.xlsx
in this example).
The Get-ChildItem
cmdlet returns a collection of FileInfo
and DirectoryInfo
objects. The ForEach-Object
cmdlet is then used to iterate over each object and retrieve the FullName
property, which represents the full path of the file.
Executing this command will output a list of file paths for the specified file extensions in the given directory and its subdirectories.
You can further customize the command based on your requirements. For example, you can change the file extensions or modify the directory path to fit your specific use case.