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: I need to move thousands of files from one folder to new folders


28 Oct 2011   #1

XP 64 AND WINDOWS 7 32BIT
 
 
I need to move thousands of files from one folder to new folders

I need to figure out a way to take thousands of .dwg,.docx,.xlsx, ect. files and organize them all into folders. I want to take file named 54321.xlsx and 54321.docx and put them in the folder 54321. Right now all my .docx files are in a folder, but I want them all seperated by seperate folders. I have already made the 100k folders for each job using a batch file. Now I just need to figure out how to organize the files into the corresponding folders. Please Help!

My System SpecsSystem Spec
.

28 Oct 2011   #2

Win 8 Release candidate 8400
 
 

Quote   Quote: Originally Posted by RHODESSURVEYING View Post
I need to figure out a way to take thousands of .dwg,.docx,.xlsx, ect. files and organize them all into folders. I want to take file named 54321.xlsx and 54321.docx and put them in the folder 54321. Right now all my .docx files are in a folder, but I want them all seperated by seperate folders. I have already made the 100k folders for each job using a batch file. Now I just need to figure out how to organize the files into the corresponding folders. Please Help!
One caveat. That many nested folders will slow the computer to a crawl unless you have really good hardware (RAM (8gigs), CPU,. i7, etc).
My System SpecsSystem Spec
28 Oct 2011   #3

XP 64 AND WINDOWS 7 32BIT
 
 
file organizing

Thank you,
Yes I realized that already. I created subfolders to help. 80,000 files are under a file called archive. We will not need to access this much. 8,000 are in a different sub folder and we only have 2,000 folders in the main file. I just need to figure out how to get our files in the correct folders.
My System SpecsSystem Spec
.


28 Oct 2011   #4

Windows 7 x64 Ultimate
 
 

Well this is really a job for a 20-30 line script. Python, perl whatever...

Don't know what your skill level with that sort of thing is, but even as a coding noob it may take less time to figure out how to write a python script than to do it all by hand. (And pick up an awesome skill for future problems like this at the same time)

(An experienced scripter could probably do it in 5 minutes if here is anyone like that in the company)
My System SpecsSystem Spec
28 Oct 2011   #5

XP 64 AND WINDOWS 7 32BIT
 
 
wow thanks

I appreciate the info. I guess I am going to be trying to learn python script this weekend. Any direction to send me on the net to find how to do this?
My System SpecsSystem Spec
28 Oct 2011   #6

Windows 7 x64 Ultimate
 
 

Well you can google for "Python Scripting" and install the interpreter (from here http://www.python.org/) and it comes with a simple editor. Then try googling "Getting started with python". I don't have any specific site recomendations. There will be tons of sample code if you can find one that seems close to what you want to do. Like "Sort files using pyton".

For example, this sample does several of the things you will need to do for your task even though it doesn't do exactly the same thing:

Using Python to delete old files and keep newest ones : Graham Lyons

But it shows how to iterate over all files in a foilder, find information about them and then do something with them... ANd it's only 7 lines of code. Yours may be a bit longer but should still be pretty simple.
My System SpecsSystem Spec
28 Oct 2011   #7

Windows 7 32 bit
 
 

Are you planning to only access these via program or command line? I'm just thinking Explorer or any Gui file manager may choke when sifting through all the file and folder attributes.

Also wide may be better than deep if you plan on using Explorer. It balks if the length of the nested folder paths start approaching 260 characters.
My System SpecsSystem Spec
28 Oct 2011   #8

Windows 7 Home Premium 64 OEM
 
 

You know, if you're a windows nut... and you like scripts... you should be hanging out here:
Hey, Scripting Guy! How Can I Move Files Based on a Portion of the File Name? - Hey, Scripting Guy! Blog - Site Home - TechNet Blogs
That one sounds similar, but you can edit or search the site if thats not what you're looking for.
Make sure it will work on your system first. http://technet.microsoft.com/en-us/s...enter/dd940113
I've only tried this on XP so I'm not sure what may have changed with 7.
My System SpecsSystem Spec
28 Oct 2011   #9

Windows 7 32 bit
 
 

I have an AutoIt3 function that returns the "base name" of a path. For example, _FileBaseName("C:\MyFolder\MyFile.txt") returns "MyFile"

You could use it to put the file into the proper folder

Whatever programming language you decide to use should either have a canned function that does the same, or have library functions you can use to roll your own without too much difficulty

Basically it just returns the characters after the last backslash up to but not including the first extension dot

Code:
; return the basename part of a file path
; works only for files with extension
; e.g. returns "test" for c:\folder\test.exe path
;
Func _FileBaseName($path)
	If $path = "" Then Return ""
	If StringLen($path) < 3 Then Return ""

	Local $pos = StringInStr($path, "\", 0, -1)
	$pos += 1
	Local $tmp = StringMid($path, $pos)
	Return StringLeft($tmp, StringInStr($tmp, ".", 0, -1) - 1)
EndFunc   ;==>_FileBaseName
So in AutoIt3 you would do something like
$basename = _FileBaseName($path)

FileMove($basename & ".*", $basename & "\*.*)

The "&" is string concatenation operator. So it becomes "move files with base name x inside folder named x"

Should be pretty simple if the folders are all on the same level.
My System SpecsSystem Spec
Reply

 I need to move thousands of files from one folder to new folders




Thread Tools



Similar help and support threads for2: I need to move thousands of files from one folder to new folders
Thread Forum
Can't move folders or files inside Explorer Customization
Disc burning software with multisession+verify+move files/folders Software
Can't move folders with files, but can move files General Discussion
move imported mail folders to default account folder Browsers & Mail
If want move (all Sub Folders) User- Folder to another Drive General Discussion
Cannot move/copy files within folder General Discussion
automatically delete/move files to folders 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 08:38 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33