Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

batch script to create a folder in each sub-folder

Posted on 2008-10-26
2
Medium Priority
?
1,389 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

824 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