Code: Select all
rem ***********************************************
rem * Estabalish the available manifest file names
rem * Extract the first four characters of file name
rem ***********************************************
cd D:\Adsoft\SIMS\ManifestFiles
for /f %%a in ('dir /o-d /b *.mfs') do (
set FileName=%%a
set str=%%a
set str=!str:~0,4!
rem *************************************
rem * Remove the leading two zero digits
rem *************************************
set str=!str:~-2!
rem ******************************************************
rem * Remove the leading zero if file number less that 10
rem ******************************************************
if "!str:~0,1!" == "0" (
set str=!str:~-1!
)
echo !str! >> %~dp0FileNameA.csv
echo !FileName! >> %~dp0FileNameB.csv
)
set /p ManifestFileNumber=<%~dp0FileNameA.csv
The result is going into the csvfile in one column as shown in example below
50
40
30
20
10
I want to extract the output instead into a csv file that is one row only with comma separation between groups as shown in example below
50,40,30,20,10,
I need to use the numbers one at a time from the csv in another 'for' loop extracting the numbers with something like
the code below to be used with an application that is running the original file names from D:\Adsoft\SIMS\ManifestFiles directory.
Code: Select all
set Count=1
set EndCount=<number of original files in directory>
if !Count! gtr !EndCount! goto endloop
set CSV=%~dp0FileNameA.csv
for /F "tokens=%Count% delims=," %%a in (%CSV%) do (
etc
I am having trouble getting the extracted numbers into a comma delimited csv file in one row only, can anyone help please.
Tks