Solution
Yeah a script would be the most efficient especially if you have a large number of files. In powershell it would be like this
or it could be created as a function so that you can pass it different values for reuse
Code:
$CopyFromPath = "C:\Some\Path"
$CopyToRootDirectory = "C:\Some\Other\Path"
$FileTypeFilter = "*.xlsx"
$Files = Get-ChildItem -Path $CopyFromPath -Filter $FileTypeFilter
foreach($File in $Files)
{
$DirectoryName = "\$File.BaseName"
$CopyToDirectory = "$CopyToRootDirectory$DirectoryName"
if(-not(Test-Path $CopyToDirectory))
{
New-Item -Path $CopyToDirectory -ItemType Directory
}
Move-Item $File.FullName -Destination $CopyToDirectory -Forc
}
or it could be created as a function so that you can pass it different values for reuse
Code:
Function Move-ItemToDirectory
{
param...
q988988
New Member
- Joined
- Nov 21, 2019
- Messages
- 19
- Thread Author
-
- #22
How about the file names? I just did a test... the code worked fine with the file names A,B,C but not for a bit more complex names. And the code also worked fine for the folders with existing non-xlsx files. SO the only issue left would be the file names. Is it possible to make some tweaks on the code so it works for the file name such as 22B_1 or 100_2?
Similar threads
- Replies
- 1
- Views
- 49
- Replies
- 0
- Views
- 36
- Article
- Replies
- 0
- Views
- 44
- Replies
- 1
- Views
- 95