Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
Python
SQL
Shell
Markdown
YAML
JSON
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
TypeScript
Perl
Lua
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
param ( [Parameter(Mandatory = $true, ValueFromRemainingArguments = $true)] [string[]]$InputFiles ) # Get full paths of dropped files $files = $InputFiles | Where-Object { Test-Path $_ -and -not (Test-Path $_ -PathType Container) } if ($files.Count -eq 0) { Write-Host "No files provided." Read-Host -Prompt "Press Enter to exit" exit } # Extract just the file names $fileNames = $files | ForEach-Object { [System.IO.Path]::GetFileNameWithoutExtension($_) } # Find common prefix function Get-CommonPrefix { param ([string[]]$names) if ($names.Count -eq 0) { return "" } $prefix = $names[0] foreach ($name in $names) { $i = 0 while ($i -lt $prefix.Length -and $i -lt $name.Length -and $prefix[$i] -eq $name[$i]) { $i++ } $prefix = $prefix.Substring(0, $i) if ($prefix -eq "") { break } } return $prefix.Trim("_- ") } $commonPrefix = Get-CommonPrefix -names $fileNames if ([string]::IsNullOrWhiteSpace($commonPrefix)) { Write-Host "No common prefix found." Read-Host -Prompt "Press Enter to exit" exit } # Use folder of the first file as base $baseFolder = Split-Path -Path $files[0] -Parent $targetFolder = Join-Path $baseFolder $commonPrefix # Create target folder if needed if (!(Test-Path $targetFolder)) { New-Item -ItemType Directory -Path $targetFolder | Out-Null } # Move files foreach ($file in $files) { Move-Item -Path $file -Destination $targetFolder } Write-Host "Moved $($files.Count) files into '$targetFolder'" Read-Host -Prompt "Press Enter to exit"
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year