Solved

batch script to create a folder in each sub-folder

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

16 Experts available now in Live!

Get 1:1 Help Now