|
Answer» I would really appreciate anybody's help here, What I'm trying to do is the following:
1. Read the titles from a NUMBER of files within a directory. 2. CREATE a FOLDER for each file based upon its name, but not its file extension. 3. move each file into its own folder.
I would really like some help as i have over 50 GB of files and doing it individually would take me a year or two.....
Many thanksLet's say you have files in the folder named
dog.txt cow.jpg Man In The Moon.xls (etc)
(1) Is this what you WANT to do: make a folder called dog and move dog.txt into it, a folder called cow and move cow.jpg into that, make a folder called Man In The Moon and move Man In The Moon.xls into that, and keep going until all the files are done? Is that right? So instead of a folder full of files you will have a folder full of sub folders, each with one file in it?
(2) Will there be any files with different extensions but the same base name e.g. Horse.jpg Horse.txt Horse.doc, and if so what are you planning to do in that situation?
Salmon,
with respect to your first point that is what i need yes, and there may be multiple files which need copying into the same folder irrespective of file extension.Try this code. It should be placed in the folder in question, saved using a name of your choosing with a .bat extension. It will not include itself in the list of files to be processed and after it has run you should find that it is the only file left in the folder, all the others having been moved into subfolders.
Code: [Select]@echo off
REM Loop through every file in this folder REM Excluding this BATCH file!
for /f "delims=" %%A in ( ' dir /b /a-d ^| find /v "%~nx0" ' ) do (
REM If a folder with the same base name REM does not exist, create it if not exist "%%~nA" md "%%~nA"
REM Move the file into the folder REM and show message to user echo Moving file: %%A to folder: %%~nA move "%%A" "%%~nA"
)
REM Complete echo Done echo. Pause
|