Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 41,104 of 42,547    |
|    Todd Vargo to z00t3r101@gmail.com    |
|    Re: batch to put files in to folder of s    |
|    24 Apr 15 12:48:44    |
   
   From: tlvargo@sbcglobal.netz   
      
   On 4/24/2015 11:48 AM, z00t3r101@gmail.com wrote:   
   > Hi,   
   >   
   > hoping for some help with this one, I have a folder with many files in it, I   
   want a batch file to create and then ,move each file in to a folder of the   
   same name file ?(which the batch file creates)   
   >   
   > im leaning towards having to run two files , i.e one to create the folders   
   using the file names file names and then he second to move the files in to the   
   folders of the same name.   
   >   
   > could anyone help with a one off script that could do this?   
   >   
      
   Since the folders will be the same name as the files, and both names can   
   not exist in the same folder at the same time, you will have to create a   
   temporary folder, move the file in it, then rename the folder. It is   
   best for this to occur within a single batch.   
      
   First you need to detect the files to be worked with.   
      
    FOR %%f IN (*.txt) DO ( {for example}   
      
   Then you need to create a new folder for each file using a temporary   
   name using something like this.   
      
    MD tempdir.   
      
   Then you use MOVE to move the current file into the temporary folder.   
      
    MOVE "%%f" tempdir   
      
   Then you use REN to rename the temporary folder to the original file   
   name like this.   
      
    REN tempdir "%%f"   
      
   Finally, finish the code with a closing parenthesis and save.   
      
    )   
      
   Hope this helps.   
      
   --   
   Todd Vargo   
   (Post questions to group only. Remove "z" to email personal messages)   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca