Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hey,
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:
/test.dxf
/test.pdf
/test.stepI like to copy the batch file in this map, double click and have this as an result:
/test/test.dxf
/test.pdf
/test.stepand if another thing is possible, autodelete that batch from that folder :-)
Thanks.Greetz Kimme

You specified this:
/test/test.dxf
/test.pdf
/test.stepDid you really mean just one of the three files should go into a new folder called test?

By test i mean the filename.
It would be like:
"filename"\"filename".pdf
\"filename".dxf
\"filename".stepI 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.
thanks

Your example is still confusing, you are showing only one file being moved into a folder.
Is this what you mean:
"filename"\"filename".pdf
"filename"\"filename".dxf
"filename"\"filename".step

I'll try to show it with more examples:
example filelist in a map:
\A.pdf
\A.dxf
\B.pdf
\B.step
\C.dxf
\C.stpAfter running the batch, that same map:
\A\A.pdf
\A\A.dxf
\B\B.pdf
\B\B.step
\C\C.dxf
\C\C.stpThe 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.
Thx

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 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 ) )

![]() |
Massive DOS script for So...
|
help me write this shell ...
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |