Solved

batch script to create a folder in each sub-folder

Posted on 2008-10-26
2
1,366 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:adnanj76
2 Comments
 
LVL 2

Accepted Solution

by:
adnanj76 earned 0 total points
ID: 22806819
Nevermind!

I got the solution after doing some tries:
============== I made the following batch to do the job =======
for /f "delims=" %%a in ('dir /ad /s /b') do (
cd /d "%%a"
md "New Folder"
move *.txt "New Folder"
)

=====================================================
Thanks anyways
0
 
LVL 5

Expert Comment

by:PaulKeating
ID: 22806847
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

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question