twig123 Posted June 6, 2008 Share Posted June 6, 2008 Hey all,I'm can seem to figure out the code to do this...I'm trying to make a batch file do a "DIR /B/ON" and list only the file names in this formatting like below into a variablefile1.exe|file2.exe|file3.exe|file4.exe (separated by a | "pipe" )Any ideas on how to go about doing so?thanks Link to comment Share on other sites More sharing options...
Scr1ptW1zard Posted June 7, 2008 Share Posted June 7, 2008 If you only want the files, use dir /b /on /a-d [d:\path].Like this:@echo offsetlocal enabledelayedexpansionfor /f "tokens=*" %%# in ('dir /b /on /a-d c:\') do set _lst_=!_lst_!%%#^^^|echo !_lst_!endlocal Link to comment Share on other sites More sharing options...
Yzöwl Posted June 7, 2008 Share Posted June 7, 2008 I cannot immediately see a reason to have this data as a variable therefore I'll assume you'd wish it in a file.In the code below, change:%userprofile%\desktop to reflect the directory you wish listing%temp%\_$out.log to reflect your intended output file@Echo off&SetlocalSet "#=%userprofile%\desktop"Set "_=%temp%\_$out.log"Type Nul>"%_%"For /f "delims=" %%_ In ('Dir/b/a-d "%#%"') Do Echo:|Set/p "=%%_|">>"%_%" Link to comment Share on other sites More sharing options...
twig123 Posted June 7, 2008 Author Share Posted June 7, 2008 (edited) @Scr1ptW1zard & Yzöwl -Thanks for the responces, I will test both suggestions and see if either formatting will work for me.I cannot immediately see a reason to have this data as a variable therefore I'll assume you'd wish it in a file. Well, I'm trying to automate boooggy's WMP11 slipstreamer to take any hotfixes in a certine folder and integrate them all, without having to manually enter the names of every fileso to end up something like this:Set Path=E:\Twig06\~Source~\Addins\2008-26-05\~files~REM -- %path% is hard coded path at the moment just for testingSet WMP11Patches=%path%\WMP11\PatchesREM Folder to place all patches for WMP11 to be slipstreamedWMP11Slipstreamer.exe /hotfix:"%WMP11Patches%|%OutputFromArrayToListFilesToRuN%"...We could also use this same approach for RyanVM integrator as well as nLite and Driverpacks, however, the output would need to be in a different format for each but still the same basic format of pulling the file names and putting them into a variable. Thus making it very easy for those of us who use the same tweaks all the time, however just need updates added to a new build, resulting in a completely unattended creation of a Windows Build.... only work required is to place the updated files into specific folders.Thanks both! Edited June 7, 2008 by twig123 Link to comment Share on other sites More sharing options...
twig123 Posted June 7, 2008 Author Share Posted June 7, 2008 @Yzöwl -I tested and your coding is working very well! If it is possible, the only other things are to place the output into a variable and to remove the | (pipe) after the very last file.Ex: take the output from the above code "file1.exe|file2.exe|file3.exe|" and remove the | after file3.exeA very greatful Twig says TYVM for taking the time to try to helpme in my quests Link to comment Share on other sites More sharing options...
Yzöwl Posted June 7, 2008 Share Posted June 7, 2008 Well I've no idea about this tool or its commandline options etc. therefore I'll assume that your above command is correct and take a stab at this!@Echo off&SetlocalSet p_=E:\Twig06\~Source~\Addins\2008-26-05\~files~Set #=%p_%\WMP11\PatchesSet "_=%temp%\_$out.log"Type Nul>%_%For /f "delims=" %%_ In ('Dir/b/a-d "%#%"') Do Echo:|Set/p "=%%_|">>%_%For /f "usebackq delims=" %%_ In ("%_%") Do (Set $="%%_")Del %_%&Set $="%$:~1,-2%"For /f "delims=" %%_ In (%$%) Do ( Start "" /wait WMP11Slipstreamer.exe /hotfix:"%#%|%%_") Link to comment Share on other sites More sharing options...
twig123 Posted June 7, 2008 Author Share Posted June 7, 2008 (edited) Here, this might help:the output for the WMP11Slipstreamer.exe /hotfix: command is what we are trying to achive. The needed format is:WMP11Slipstreamer.exe /hotfix:"FolderPathToHotfixes|hotfix1.exe|hotfix2.exe|hotfix3.exe" ...etc... so we shouldn't need to send the output through another array. so the output to that is being put into the _$out.log is exactly the info we need to throw into the after the /hotfix:" switch (minus the end | )to look the final output like this:Set p_=E:\Twig06\~Source~\Addins\2008-26-05\~files~Set #=%p_%\WMP11\PatchesSet "_=%temp%\_$out.log"WMP11Slipstreamer.exe /hotfix:"%#%|OutputFrom_$out.log(MinusTrailing|)"another example (exact syntax as if I were manually typing this info into a command line):WMP11Slipstreamer.exe /hotfix:"E:\Twig06\~Source~\Addins\2008-26-05\~files~\WMP11\Patches|kb928788.exe|kb929399.exe|kb929773.exe"(forum makes it look like this is multiple lines, but it is actually all on the same line) Edited June 7, 2008 by twig123 Link to comment Share on other sites More sharing options...
Yzöwl Posted June 7, 2008 Share Posted June 7, 2008 The example I gave was intended to do just that!Is there something I missed? did you try it as is? Link to comment Share on other sites More sharing options...
twig123 Posted June 7, 2008 Author Share Posted June 7, 2008 Sry, i just looked at it b4...I guess I didn't understand why it would go through a 2nd array... but you are right, it does exactly what I was wanting TYVM!(I might have to contract your services again if I get stuck with the other 2 programs, but I will take a stab at those for now, I just couldn't figure out how to get the |'s in there, as it would keep telling me it was an invalid syntax every time I tried something.)Thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now