How to search folders ending with a character windows

0

I have a many folders, I want to select all ending with 30 and move them to another folder, can that be done easily in windows or DOS ?

Image

Its a one-off task

Duffer

Posted 2018-08-30T04:49:28.950

Reputation: 101

It is a sheduled task or one-off? – Akina – 2018-08-30T05:12:46.630

1

I would consider Powershell. You can open a Powershell prompt and use the move-item (https://docs.microsoft.com/powershell/module/microsoft.powershell.management/move-item) command, that will take *30 as the -Path. E.g. move-item C:\test\*30 C:\temp\

– HelpingHand – 2018-08-30T05:51:10.383

Answers

2

You can use the powershell script below to reach your needs.

$copy=Get-PSDrive -PSProvider FileSystem  |  %{ Get-ChildItem $_.Root -directory -Recurse -force  -ErrorAction SilentlyContinue| Where-Object {$_.basename -match ".*30$"}}
Copy-Item -Path $copy.Fullname -Destination D:\TEST\ 

You just need to change the "D:\TEST\" in the code to the path where you want to place these folders.

Note: This code is to copy the matching folders to the new folder. If you want to cut them to a new folder, you need to change the first "Copy" in the second line of code to "Move". Also, some folders may contain system files and you may not have permission to move them.

S.Leon

Posted 2018-08-30T04:49:28.950

Reputation: 335

1

A simple Powershell one-liner:

PS C:\> Get-ChildItem -Path C:\source\* -Directory -Filter *30 | Move-Item -Destination C:\destination\

On the GUI use the "*30" kind:=folder filter in the Search Tool:

enter image description here

bcs78

Posted 2018-08-30T04:49:28.950

Reputation: 723