I have a folder c:\graphics (root) and a program that creates subfolders e.g. aa, bm, czx, mjpq, zz (I have many subfolders, the length is variable).
In each subfolder, I have 26 files and one folder. For example, aa folder has: aa_000.jpg, aa_001.jpg, ..., aa_023.jpg; other two files aa_360.jpg, aa.html and a folder. The complete path is C:\graphics\aa\aa_360.
I need to move 24 files (aa_000.jpg, aa_001.jpg, ..., aa_023.jpg) in subfolder c:\graphics\aa\aa_360 and also equal to each subfolder.
Another example is c:\graphics\mjpq\mjpq_360, should have mjpq_000.jpg, ..., mjpq_023.jpg.
I started the script, thinking move all .jpg (25 files) in the subfolder (later, I had to think like extract the xxx_360.jpg) but it doesn't work:
Get-ChildItem c:\graphics -rec | where-object {$_.extension -match "jpg"} | ForEach-object {$newPath =(Get-Location).toString()+(Get-Location).ToString().SubString(10)+"_360"); Move-Item $_.FullName $newPath}
but Get-Location doesn't find the file path.
NOTE: I found a solution that is working, but it throw some errors in the console:
Get-ChildItem c:\graphics -rec | where-object {$_.extension -match "jpg" -and (!($_.name -like "*360*"))} | ForEach-Object {$newPath =($_.DirectoryName).toString()+($_.DirectoryName).ToString().SubString(10)+"_360"; Move-Item $_.FullName $newPath}