Making Folders from .pdf, .step or .dxf

October 20, 2009 at 08:01:01
Specs: Windows XP

Iv'e looked around a bit but all the script i
found, just dont do the trick.

can somebody help me out please?

I generate different files with the same name.
I would like them to end up in a folder named that way.

for example:


I like to copy the batch file in this map, double click and have this as an result:


and if another thing is possible, autodelete that batch from that folder :-)


Greetz Kimme

See More: Making Folders from .pdf, .step or .dxf

Report •

October 20, 2009 at 09:55:40
You specified this:


Did you really mean just one of the three files should go into a new folder called test?

Report •

October 21, 2009 at 02:01:13
By test i mean the filename.

It would be like:


I would like the batch, not to look for the extension.

Regardless of what the extension is, put all the same
filenames in a folder named after the filename.

I hope that that is possible.


Report •

October 21, 2009 at 08:33:45
Your example is still confusing, you are showing only one file being moved into a folder.

Is this what you mean:


Report •

Related Solutions

October 21, 2009 at 23:40:49
I'll try to show it with more examples:

example filelist in a map:


After running the batch, that same map:


The batch has created a folder by filename
If there are 2 files with the same name, he'll just move them
both in one folder.

In the end you'll have a list of folder, all containing there
'foldername' files with multiple extensions.

I hope this is more clear.


Report •

October 22, 2009 at 02:23:08
Here's the script that does the job. It takes precautions in case there are any files without extension: if a file is called X, it moves it into X\X by temporarily renaming X. If you can be absolutely sure there are no files without extension in that folder, you can simplify the batch file.

I don't like autodeleting batch files, because I once wrote a batch file that accidentally deleted the only copy I had. But if you must, you can add DEL "%~f0" as the last line.

@echo off
rem Move each file except this batch file into a new folder with the same base
rem name as itself.
rem Note: In batch scripts, %%~nf gives the base name (i.e. without extension)
rem of the file %%f in a FOR loop (type FOR /? for help.) So for every file
rem %%f, rem we create the folder %%~nf if it doesn't already exist, and move
rem the file into that folder. Care is taken when creating a new folder in case
rem there is a file with the same name as the folder and no extension (i.e.
rem when "%%~nf" == "%%f"). We enclose all file names in quotes in case there
rem are any spaces in the file names.

for %%f in (*) do if not "%%~ff" == "%~f0" (
   if not "%%~nf" == "%%f" (
      if not exist "%%~nf\" md "%%~nf"
      move "%%f" "%%~nf\" >nul
   ) else (
      ren "%%f" "%%f.temporarily_renamed"
      md "%%~nf"
      move "%%f.temporarily_renamed" "%%~nf\%%f" >nul

Report •

October 22, 2009 at 07:22:15

Thank you very much!

Report •

Ask Question