Solved

batch script to create a folder in each sub-folder

Posted on 2008-10-26
2
1,364 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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 …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now