Answer the question
In order to leave comments, you need to log in
Do you need a script that will search for files with the same name, create folders with the same name for these files, and move them there?
We need a script that will search for files with the same name, create folders with the same name for these files and transfer them there.
For example, there are six files in one folder: 1.txt , 1.png , 2.txt , 2.png , 3.txt , 3.png .
After the script has run, three folders should appear in which our files will be transferred: in the folder with the appeared name "1" there will be files: 1.txt , 1.png ; in folder "2" there will be files: 2.txt , 2.png , and in folder "3" respectively: 3.txt , 3.png .
Maybe this chain of actions is easier not to do in the total, but in some other program.
Maestro and gurus, help a person who does not understand this.
Answer the question
In order to leave comments, you need to log in
A simple powershell script
$searchfolder = "j:\1"
$storefolder = "j:\2"
New-Item $storefolder -ItemType Directory -ErrorAction SilentlyContinue -Force
Get-ChildItem $searchfolder -File -Recurse | %{
$newpath = Join-Path $storefolder -ChildPath $_.BaseName
New-Item $newpath -ItemType Directory -ErrorAction SilentlyContinue -Force
Move-Item -LiteralPath $_.FullName -Destination $newpath
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question