Link to home
Start Free TrialLog in
Avatar of adnanj76
adnanj76

asked on

batch script to create a folder in each sub-folder

I need a batch script to perform some file functions, I have user directories like:
user1
user2
user3
...so on

In each of user folder there are some files.
I'd like to make a new folder called "Archive Files" in each user directory and move only the specific files on their root folder (i.e. user1/*.xyz) to the "Archive Folder"

Once again, I need a script to:
1- Go in user folder
2- Create a directory called "Archive Files"
3- Move the *.xyz files in "userX" to the "Archive Files" folder
4- then start the step 1 again to the next user directory.

Thanks, I would really appriciate your help.
ASKER CERTIFIED SOLUTION
Avatar of adnanj76
adnanj76

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
This is intended to be run from the folder that contains user1, user2, user3 etc.

rem Create the archive folders if not already there
for /f %%f in ('dir user* /b /ad') do if not exist %%f\"Archive Folder" md %%f\"Archive Folder"
rem Archive the files
for /f %%f in ('dir user* /b /ad') do move /y %%f\*.xyz %%f\"Archive Folder"

Open in new window