Computing.Net > Forums > Programming > Making Folders from .pdf, .step or .dxf

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.

Making Folders from .pdf, .step or .dxf

Reply to Message Icon

Name: Kimme
Date: October 20, 2009 at 08:01:01 Pacific
OS: Windows XP
Subcategory: Batch
Tags: DOS, batch, name
Comment:

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.step

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

/test/test.dxf
/test.pdf
/test.step

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


Thanks.

Greetz Kimme



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: October 20, 2009 at 09:55:40 Pacific
Reply:

You specified this:

/test/test.dxf
/test.pdf
/test.step

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


0

Response Number 2
Name: Kimme
Date: October 21, 2009 at 02:01:13 Pacific
Reply:

By test i mean the filename.

It would be like:

"filename"\"filename".pdf
\"filename".dxf
\"filename".step

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.

thanks


0

Response Number 3
Name: klint
Date: October 21, 2009 at 08:33:45 Pacific
Reply:

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


1

Response Number 4
Name: Kimme
Date: October 21, 2009 at 23:40:49 Pacific
Reply:

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.stp

After running the batch, that same map:

\A\A.pdf
\A\A.dxf
\B\B.pdf
\B\B.step
\C\C.dxf
\C\C.stp

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.

Thx


0

Response Number 5
Name: klint
Date: October 22, 2009 at 02:23:08 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: Kimme
Date: October 22, 2009 at 07:22:15 Pacific
Reply:

WOOT,

Thank you very much!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Massive DOS script for So... help me write this shell ...


Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Making Folders from .pdf, .step or .dxf

batchfile to create folders from fi www.computing.net/answers/programming/batchfile-to-create-folders-from-fi/17066.html

extracting text from *.pdf files www.computing.net/answers/programming/extracting-text-from-pdf-files/20250.html

Delete a common folder from many folders www.computing.net/answers/programming/delete-a-common-folder-from-many-folders/19347.html