i have everytime a messy desktop, because i forget to save the Files in the right binder. Now i searcht on GitHub and else, for a programm who read every Friday my desktop binder, and than it moves all fiels with a Audio extension to the Audio binder, and the sae with Text, Pictures and other datas.
Maybe i can define the extensions self, but i dont now the code for the reading part. I tried to make it self but it don't work. And the code should run on power shell.
Thank you for your help
$desktopPath = [Environment]::GetFolderPath('Desktop')
$destinationPath = 'C:\Path\to\Destination\Folder'
# Get all files on the desktop
$files = Get-ChildItem -Path $desktopPath -File
# Filter files based on criteria (e.g., file extension)
$filteredFiles = $files | Where-Object { $_.Extension -eq '.txt' }
# Create the destination folder if it doesn't exist
if (-not (Test-Path -Path $destinationPath)) {
New-Item -Path $destinationPath -ItemType Directory | Out-Null
}
# Move filtered files to the destination folder
foreach ($file in $filteredFiles) {
Move-Item -Path $file.FullName -Destination $destinationPath
}
To run a script e.g. every Friday you have to include it into the Windows Task Scheduler