Online Marketplaces Depop Wins

Constantly renaming files you want to save is such a pain.. I found a little script that lets you just drop images into a folder and it will rename them for you. See quote below. Make a new file in the folder you want to use and name it watch.ps1. Copy the contents of the quote into the file. Run in powershell while you're dragging files into the folder. Click the powershell window and hit ctrl+c when you want it to stop running. If you start it back up again, it picks up where you left off.

It would also be possible to write something that would let you skim the entire lot of items someone is selling and rename the image files based on whom the seller is, but I'm kinda too lazy to do that right now.

# Made by Qwerty
# Inspired by

# Run this script by '.\watch.ps1' to start watching current folder.
# Stop by pressing Ctrl+C

try {
$watcher = New-Object IO.FileSystemWatcher -Property @{
Path = '.'
Filter = '*.*'
IncludeSubdirectories = $true
NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'
}

$action = {
$details = $Event.SourceEventArgs
$Path = $details.FullPath
$Name = $details.Name
$OldName = $details.OldName
$filename = [io.path]::GetFileNameWithoutExtension($Name)
$ext = [io.path]::GetExtension($Name)

if ( $OldName -eq $null ) {
$count = 0
do {
$count = $count + 1
$newName = "$filename-$count$ext"
} while ( test-path $newName )
Move-Item $Path -Destination $newName -Force
Write-Host ""
Write-Host "$Name -> $newName" -ForegroundColor DarkYellow
}
}

$handlers = . { # available event types: Created Deleted Changed Renamed
Register-ObjectEvent -InputObject $watcher -EventName Created -Action $action
}

# Monitoring starts now:
$watcher.EnableRaisingEvents = $true
Write-Host "Watching for changes. Press Ctrl+C to stop."

# Use an endless loop to keep PowerShell busy.
do {
Wait-Event -Timeout 1
Write-Host "." -NoNewline # write a dot to indicate we are still monitoring
} while ($true)
} finally {
# This gets executed when user presses CTRL+C:

$watcher.EnableRaisingEvents = $false
$handlers | ForEach-Object { Unregister-Event -SourceIdentifier $_.Name }
$handlers | Remove-Job
$watcher.Dispose()

Write-Host ""
Write-Host "Event Handler disabled, watching ends."
}
 
Comment

 
Comment