Aufgrund meines (möglicherweise fehlerhaften) Verständnisses dessen, was Sie möchten, können Sie dies mit dem folgenden PowerShell-Skript tun. Beachten Sie, dass dies von einer Arbeit von mousio stammt, die unter Rekursiv tausende Dateien in Unterordner-Fenster verschoben wird .
# If run from "P:\Gopro\2018", we can get the file list. $images = dir GP* # Process files one by one. foreach ($image in $images) { # Suppose $image now holds the file object for "P:\Gopro\2018\GPBK1153.FOO" # Get its file name without the extension, keeping just "GPBK1153". $filenamewithoutextension = $image.basename # Grab the first two characters (which we expect to be "GP"), # skip the next two characters (which we expect to be letters; e.g., "BK"), # then grab all the characters after that (which we expect to be digits; e.g., "1153") # and put them together, resulting in "GP1153". $destinationfolderpath = $filenamewithoutextension -replace '(..)..(.*)','$1$2' # Silently make the directory structure for "GP1153". md $destinationfolderpath > $null 2>&1 # Move the file from "P:\Gopro\2018\GPBK1153.FOO" to the new folder "P:\Gopro\2018\GP1153" move-item $image -Destination $destinationfolderpath # The file is now available at "P:\Gopro\2018\GP1153\GPBK1153.FOO". }