Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: [Help] Batch File move every 15.000 files to another folders

25 Jun 2014   #1
SevenDP

Windows 7 Profesional 32bit
 
 
[Help] Batch File move every 15.000 files to another folders

Hi guys
I'm new here, please help

I have about 2 million email files that i want to convert into mbox files.
but the tool i used only can convert every 15.000 files.
so i need a batch file that can move this 2 million files into another folder (15.000 files each folder)
and the folder name is automatically created (counter).
example:

folder 1 contain 15.000 files
folder 2 contain next 15.000 files
.....
folder 134 contain the rest of files ...

note:
2.000.000 / 15.000 = 133,333 so there will be 134 folders

if can, i hope the files will be renamed too ... (adding ".eml")
example: file name 12345678.123456.abcde moved and renamed to 12345678.123456.abcde.eml

i already have the solution for linux, but i do not have any idea in windows

please help
and sorry for my english

thanks


My System SpecsSystem Spec
.
25 Jun 2014   #2
Slartybart

x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
 
 

Are you going to do this on a regular basis?

Do you want only 15,000 files in each folder or would you prefer to have all of the files in one folder?

Are the files currently in different folders?

I think you can just copy the files to a new location renaming them in the copy process
You have to use copy in Command Prompt, you cannot do this in Windows.

Try this as a test:
Make two new folders to test the process. They can be any name in any location, but I'll use C:\DirA_Src and C:\DirB_Dest as examples
Copy a few (20?) files that you want to rename to C:\DirA_Src folder. If the files have different extensions, that would be a good test.

Launch Command Prompt
Navigate to C:\DirA_Src and list the contents
cd C:\DirA_Src
dir
The try a rename with copy
copy *.* C:\DirB_Dest\*.*.eml
That might be difficult to decipher so I'll put the strings on separate lines
copy
*.*
C:\DirB_Dest\*.*.eml

The command has to be entered on one line, just know that there is a space between each string I show on separate lines. Also be aware that a space in the new folder names will require parenthesis around the folder name, so I recommend not having any spaces in the new folder names (note that I used the underscore character)

If that does what you want, then you can use the process to copy all of your files to any folder you choose.

Try it an let me know if it works or if you have other questions.
My System SpecsSystem Spec
25 Jun 2014   #3
SevenDP

Windows 7 Profesional 32bit
 
 

Quote   Quote: Originally Posted by Slartybart View Post
Are you going to do this on a regular basis?

Do you want only 15,000 files in each folder or would you prefer to have all of the files in one folder?

Are the files currently in different folders?

I think you can just copy the files to a new location renaming them in the copy process
You have to use copy in Command Prompt, you cannot do this in Windows.

Try this as a test:
Make two new folders to test the process. They can be any name in any location, but I'll use C:\DirA_Src and C:\DirB_Dest as examples
Copy a few (20?) files that you want to rename to C:\DirA_Src folder. If the files have different extensions, that would be a good test.

Launch Command Prompt
Navigate to C:\DirA_Src and list the contents
cd C:\DirA_Src
dir
The try a rename with copy
copy *.* C:\DirB_Dest\*.*.eml
That might be difficult to decipher so I'll put the strings on separate lines
copy
*.*
C:\DirB_Dest\*.*.eml

The command has to be entered on one line, just know that there is a space between each string I show on separate lines. Also be aware that a space in the new folder names will require parenthesis around the folder name, so I recommend not having any spaces in the new folder names (note that I used the underscore character)

If that does what you want, then you can use the process to copy all of your files to any folder you choose.

Try it an let me know if it works or if you have other questions.


Hi Slartybart
renaming file was ok. thanks for your information.

About moving file,
It is not regular basis, i just want to do that if the email files > 1 million files.

example:
I have directory "c:\all" contains 2 million files
I want files in "c:\all" moved in new folder every 15.000 files

I need a batch files, so the result:

"c:\result\1" contain 15.000 files
"c:\result\2" contain next 15.000 files
etc

thanks
My System SpecsSystem Spec
.

26 Jun 2014   #4
Slartybart

x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
 
 

Ok, let me think about this. I thought the 15,000 limit was due to the tool you were using.

But I see now that you only want 15,000 files in each sub-folder.

It's going to be simple using a for statement, I just need to brush up on that and then I'll ask you to run another test before doing the entire 2 million.

Do you want to copy the files or move them. Same idea, copy/rename... move/rename - different command that's all.
Oh - I see... you did say move - ok.

Bill
My System SpecsSystem Spec
26 Jun 2014   #5
Slartybart

x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
 
 

I'm rustier than I thought.

The basic move batch is easy, but I'm having a hard time figuring out the loop control (limit to 15000). Programming it would be easy (rusty there too though ) - batch command files aren't really meant for complex logic.

It will take me a little longer to find and test - I'm sure it can be done, I'm probably just looking at it the wrong way.
while x is less than 15000
move the file (rename in move)
simple enough - but I keep moving all of the files in my test folder (I lowered the count to 3 instead of 15000)

Anyway, I'll keep trying different approaches to the loop control.
My System SpecsSystem Spec
26 Jun 2014   #6
SevenDP

Windows 7 Profesional 32bit
 
 

Hi Slartybart
Yes i want 15.000 files in each folder because the tool i use only can convert about 15.000 files in one process.
the idea is simple ... but i do not know how to implemented on windows batch ...
maybe i should mount the hdd into a linux computer and process there



thanks
My System SpecsSystem Spec
27 Jun 2014   #7
Slartybart

x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
 
 

That's where I'm getting confused - the tool. I thought you needed a batch file to replace the tool due to the 15,000 file limit. It sounds as though you still will be using the tool after the "conversion" by copy.

Should I spend any more time on the batch file or are you going to use Linux?
My System SpecsSystem Spec
01 Jul 2014   #8
SevenDP

Windows 7 Profesional 32bit
 
 

Hi Slartybart
The tool i used is Thunderbird add-on : Import email from maildir format into Mbox format.
I will going to use Linux's script then ... thanks for your help
regards,
denny
My System SpecsSystem Spec
01 Jul 2014   #9
Slartybart

x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
 
 

Thanks Denny,

I can continue trying to write the batch file, but didn't want to spend any time if you didn't need it.
I have a fairly basic bat that works for all files, but I'm hitting a snag when it comes to breaking out of the loop (stopping at 15,000). I'm sure there's an easy way to do it, but I'm rustier than I thought

Bill
.
My System SpecsSystem Spec
01 Jul 2014   #10
edmscan

Windows 7 Home Premium
 
 

It will be fun .. I was going to suggest Robocopy but that is more for fast copying of files.

Hmm .. will have to think on this one.
My System SpecsSystem Spec
Reply

 [Help] Batch File move every 15.000 files to another folders




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Batch File to Move a list of files.
Hey All, I just joined this forum to find some help on a specific topic that I've been researching for like two hours now on google. I have a list of 1300 files that I need to move from one location to another (move not copy). I've found this batch file created by Neutron16 which performs a Move...
General Discussion
Batch file to Sort and Move specific files by identifying word inside
Hi All... I will explain what I need in as much detail as possible. I need a batch file to move specific files into a separate folder,possibly by opening my hex editor,searching for the word "body" ( without the quotes ) and if found ,close hex editor,move file to a folder called "moved" ,then go...
General Discussion
a simple batch file for copy files and folders
I want to write a batch file that do this for me: - makes a directory with the "yy.mm.dd.hh.mm" as the directory name, - copies files and folders from a TEST directory to above destination, - copies only new (or modified) files from the TEST directory to a separate folder. Any Idea?
General Discussion
Batch file to move desktop icons so ALL are sorted.
Win7 stores desktop icons in two different folders: C:\Users\Public\Public Desktop C:\Users\UserName\Desktop This results in two groups of sorted icons on the desktop. I want to move all of the icons in the "C:\Users\Public\Public Desktop" to the "C:\Users\UserName\Desktop". This will...
General Discussion
Batch file to move (many) duplicted folder contents - Help!!
Hope I can explain my difficulty. I have duplicated folders album name for all my music files. As there is quite a considerable number I wondered if it was possible to batch file (automate) the process. I can not delete "d" as this would delete all the tracks. What I need to do is move the...
General Discussion
How to create a batch file that will move files based on the file type
How to create a batch file that will move files based on the file type? My Requirement : I need a batch file to copy all .doc files in all my HardDisk to a removable disk say (Z: drive) . Can anyone make it possible using a batch file?Please...Its urgent...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 09:38.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App