Create folders and move files based on name

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
AdamS
Posts: 2
Joined: 13 Aug 2019 00:15

Create folders and move files based on name

#1 Post by AdamS » 13 Aug 2019 00:29

Hey all, I'm fairly new to creating batch files so please a little patience as I have a rather specific need and to be honest I'm not sure if batch is the way to go here.

I have a folder with thousands of files inside it, the naming convention is like this:
Parent folder
001

Files in parent folder
ALS.001.000001
ALS.001.000002
ALS.001.000003
etc....
ALS.001.004325

The goal here is to create a batch script that will do the following:
1 - Parse the '001' parent folder and identify the first 999 files (ALS.001.000001 TO ALS.001.000999)
2 - Create a new folder titled '000' which will be a new subfolder of '001'
3 - Move the first 999 files to this new 000 folder
4 - Continue parsing the '001' folder for the next 999 files (ALS.001.001000 TO ALS.001.001999)
5 - Create a new folder titled '001' which will be a new subfolder of the parent '001', and move these 999 new documents into it.

And so on until there is less than 999 files which become the last batch of files to be moved into the newly created subfolder, then stop.

We would then end up with a folder structure like
001
-->000 - Contains the fist 999 files
-->001 - Contains the next 999 files
-->002 - contains the next 999 files
-->003 contains the next 999 files
-->004 contains the last 349 files (for example)

The folder and file names are arbitrary, I just use those examples as they are pretty close to what I will actually be needed.

Am I dreaming thinking this can be done with a batch script?

AdamS
Posts: 2
Joined: 13 Aug 2019 00:15

Re: Create folders and move files based on name

#2 Post by AdamS » 13 Aug 2019 18:31

Hey, sorry to answer my own post but after I posted I kept looking for a solution and it turns out the simplest idea is sometimes the best.

It turns out the software I was using to produce the files and folders has the capability to do what I want built in, I just hadn't explored all the options fully.

For the OCD people out there who need closure (like me) I was talking about an e-Discovery loadfile created to view in Relativity software. Anyone in that field will know exactly what I'm on about.

Post Reply