Link to home
Start Free TrialLog in
Avatar of Basssque
Basssque

asked on

Scripting a move of folders that do not end with two digits

Can someone provide me with a script that will only move folders that "do not" end with two digits to another folder?  Thanks!
Avatar of NVIT
NVIT
Flag of United States of America image

- Make a .bat file of this.
- Make a test folder named c:\testdir and c:\targetdir
- Copy some folders to c:\testdir. Be sure to include a mix folders that do and don't end with 2 digits.
- Run the .bat in a cmd window

for /d %%c in (c:\testdir\*) do (move "%%c" "c:\targetdir" | findstr /v /r "^.*[0-9][0-9]")

Open in new window

SOLUTION
Avatar of Jose Torres
Jose Torres
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Basssque
Basssque

ASKER

That seems to be formatted to move files opposed to folders.
I changed to to what I thought may work, but it doesn't move anything.
for /f %%c in (c:\folders\*) do (move "%%c" "c:\ARCHIVE\" | findstr /vc:"^*[0-9][0-9]")
> That seems to be formatted to move files opposed to folders.
It works fine here. Apart from folder names, your code differs from my posted one. It should be:
for /d %%c in (c:\folders\*) do (move "%%c" "c:\ARCHIVE" | findstr /v /r "^.*[0-9][0-9]")

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops, typo. Of course it is -Exclude, not -Include.