Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 10-13-2009, 01:07 PM   #1
Solid State Member
 
Join Date: Oct 2009
Posts: 16
Default Create folders based on filename

Hey again guys,

Just a quick request. I've spent a couple hours searching the net for a batch file (or similar) that can create folders based on the file names in a directory and then move those files into the folders, e.g.

Root Folder
- File A
- File B

Becomes:
Root Folder
- Folder A (File A inside)
- Folder B (File B inside)

I want to retain the filenames as the folder names but don't need the extension on the folders. I did stumble across something so close to perfect it hurts but unfortunately, doesn't work if the filenames contain spaces. Anybody here good with batch files?

Closest i've found is the command line:
For %J in (Your_Folder\*.*) Do @(MD %~dpnJ & move %J %~dpnJ)

Works perfect... except if the filenames have spaces :\
Could anyone give us a hand?

If it matters, I'm moving about 300 files - mostly video.
__________________

Chickensoup is offline   Reply With Quote
Old 10-15-2009, 09:06 PM   #2
Solid State Member
 
Join Date: Oct 2009
Posts: 16
Thumbs up Re: Create folders based on filename

Fixed my own problem :P

Ran a free batch rename program that I have to replace all spaces with underscores then re-ran the above batch file and wham! Worked perfect. Re-ran the batch rename program after to rename the folders and filenames back to spaces.

Long live freeware!
Chickensoup is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



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


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0