Computing.Net > Forums > Programming > Creating folders automatically!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Creating folders automatically!

Reply to Message Icon

Name: skshah39
Date: November 4, 2008 at 08:25:33 Pacific
OS: Win XP
CPU/Ram: Intel Core2 Duo
Product: Dell
Comment:

I'm trying to organize an external hard drive that contains thousands of files. The files are named such as:

00001-a.*
00001-b.*
00002-a.*
00003-a.*
00003-b.*
00003-c.*
etc....

I would like to create folder for each of the file names up to the delimiter hyphen and then move all the associated files into that folder. In this case, 00001 a and b would be in a folder 00001 which was just created. 00002-a would be in folder 00002, etc. The files don't all have five digits in the first part of the file name, but they all seem to have the hyphen delimiter.

Overall, I think a script that would take the file name up to the hyphen, create a folder named after it, and then move every file with that name up to the hyphen regardless of what's after the hyphen in to the newly created folder is what I'm looking for. Does that make sense?

Any help would really be great!
Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: November 4, 2008 at 19:39:26 Pacific
Reply:

Untested:

FOR /F "delims=-" %%a IN ('DIR /a-d /b') DO MD "%%a" 2>NUL

FOR %%a IN (*) DO FOR /F "delims=-" %%b IN ("%%a") DO MOVE "%%a" "%%b"



0

Response Number 2
Name: skshah39
Date: November 5, 2008 at 06:24:40 Pacific
Reply:

Thanks for the quick reply! I'm not quite sure how to implement this though. Could you break down what each part of the command does, or tell me where I could look it up?

Is /F the folder location?

Finally, do I just put this into the dos prompt?


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Creating folders automatically!

name folder automatically with ~ www.computing.net/answers/programming/name-folder-automatically-with-/14723.html

VBscripting to create folders www.computing.net/answers/programming/vbscripting-to-create-folders/13391.html

Batch file, creating folders & FTP www.computing.net/answers/programming/batch-file-creating-folders-ftp/18448.html