Here's a cool powershell script I wrote to keep my download folder organized. I have it setup to run automatically every day via Windows Task Scheduler. The last command is a call to
CCleaner. If you don't have that installed, you should remove that line.
You'll need to change the directory variable "$downloadDir" to the location of your download folder.
Save the following code as a powershell script (eg: cleanup.ps1) and run it with powershell.
# Set this variable to your download directory (don't have a trailing '\')
$downloadDir = "C:\Users\jeremiah\Downloads";
# remove all torrent files
Write-Host "Deleting .torrent files..."
remove-item $downloadDir\*.torrent
# organize download folder
#create some folders:
Write-Host "Creating main directories..."
if(!(Test-Path $downloadDir\exe)) {
mkdir $downloadDir\exe
}
if(!(Test-Path $downloadDir\zip)) {
mkdir $downloadDir\zip
}
if(!(Test-Path $downloadDir\text)) {
mkdir $downloadDir\text
}
if(!(Test-Path $downloadDir\images)) {
mkdir $downloadDir\images
}
if(!(Test-Path $downloadDir\songs)) {
mkdir $downloadDir\songs
}
Write-Host "Moving files to their folders..."
Move-Item $downloadDir\*.exe $downloadDir\exe -force
Move-Item $downloadDir\*.msi $downloadDir\exe -force
Move-Item $downloadDir\*.txt $downloadDir\text -force
Move-Item $downloadDir\*.log $downloadDir\text -force
Move-Item $downloadDir\*.zip $downloadDir\zip -force
Move-Item $downloadDir\*.7z $downloadDir\zip -force
Move-Item $downloadDir\*.rar $downloadDir\zip -force
Move-Item $downloadDir\*.tar $downloadDir\zip -force
Move-Item $downloadDir\*.gz $downloadDir\zip -force
Move-Item $downloadDir\*.jpg $downloadDir\images -force
Move-Item $downloadDir\*.jepg $downloadDir\images -force
Move-Item $downloadDir\*.png $downloadDir\images -force
Move-Item $downloadDir\*.gif $downloadDir\images -force
Move-Item $downloadDir\*.tif $downloadDir\images -force
Move-Item $downloadDir\*.tiff $downloadDir\images -force
Move-Item $downloadDir\*.m4a $downloadDir\songs -force
Move-Item $downloadDir\*.mp3 $downloadDir\songs -force
Move-Item $downloadDir\*.wav $downloadDir\songs -force
# Put the rest of the files in a folder with their extension as the folder name
$files = Get-ChildItem $downloadDir\* -include *.*
if($files.length -gt 0)
{
foreach($file in $files)
{
$ext = [System.IO.Path]::GetExtension($file)
$ext = $ext.Trim(".")
if(!(Test-Path $downloadDir\$ext)) {
mkdir $downloadDir\$ext
}
Move-Item $file $downloadDir\$ext -force
}
}
# run ccleaner
Write-Host "Running CCleaner..."
&'C:\Program Files\CCleaner\CCleaner64.exe' /AUTO
Write-Host "All Done! Exiting."