home bbs files messages ]

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 40,562 of 42,547   
   Todd Vargo to Nathan Wilson   
   Re: Dynamic Setting of variable based on   
   14 Nov 12 07:21:37   
   
   f8d7f8ea   
   From: tlvargo@sbcglobal.netz   
      
   On 11/15/2012 6:53 AM, Nathan Wilson wrote:   
   > Hi all   
   >   
   > I suppose it sounds like a simple matter but for someone who has not   
   > done this in ages I am struggling.   
   >   
   > I have a directory structure on a remote server   
   >   
   > X:\A\B\w.txt   
   > X:\A\C\x.txt   
   > X:\A\D\y.txt   
   > X:\A\E\z.txt   
   >   
   > Ok i can xcopy the Base folder eg xcopy x:\A /S to re-create the   
   > folder structure locally and the /S will ensure that only folders with   
   > content will be copied   
   >   
   > I need to then go to each folder note the folder name as a var and the   
   > process the file in the folder   
   >   
   > I have written the code to get the folder and file name but here is   
   > where I hit a major hump   
   >   
   > It only processes the last folder unless I specify a folder name   
   > manually   
   >   
   > I need the code to go to first folder, set folderName to name of   
   > folder and then get file inside   
   >   
   > Once I have folder and file name I can pass to sub routine that   
   > processes   
   >   
   > Once that is ran the process should then go to the next folder and run   
   > again replacing the folder name with the next in line   
   >   
   > So basically go to A   
   > Set folderName = B   
   > Set filename = w.txt   
   >   
   > process in sub routine   
   >   
   > go to A   
   > Set folderName = C   
   > Set filename = x.txt   
   >   
   > process etc etc   
   >   
   > Any help existing code would be very gratefuly received   
      
   In simple form...   
      
   for /d %%A in (x:\a\*) do (   
      for %%B in ("%%A\*") do call :process "%%~A" "%%~B"   
   )   
   goto :eof   
      
   :process   
   set "folderName=%~nx1"   
   set "filename=%~nx2"   
   echo Processing %filename% in %foldername%   
   echo full paths are %2 and %1   
   ::etc...   
      
      
      
   --   
   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