I’m writing a windows batch script to take a .csv as input read data in each row as variables and output unique filenames to a new .csv in Windows batch script. I’m doing this to create an inventory of thousands of analog slides I’m converting to digital.
For some reason that I cannot figure out it is not creating the output, If anyone is able to offer some insight on what is going wrong I would really appreciate it.
@echo off setlocal enabledelayedexpansion
set prefix="MyPrefix" set input_file="input.csv"
set output_file="filenames.csv"
set log_file=log.txt
rem Set up logging echo Starting the script > !log_file!
!output_file! ( for /f “skip=1 tokens=1-3 delims=,” %%a in (!input_file!) do ( set “box_num=00%%a” set “folder_num=00%%b” set “image_range=%%c” for /l %%i in (1, 1, !image_range!) do ( set “num=000%%i” set “filename=!prefix!_Box!box_num:~-2!_Folder!folder_num:~-2!_image!num:~-4!” echo !filename! ) echo Generated filenames for box !box_num:~-2!, folder !folder_num:~-2!, and image range !image_range! >> !log_file! ) )
echo Finished the script >> !log_file! echo The script has successfully completed.
A | B | C |
---|---|---|
1 | 1 | 75 |
17 | 1 | 71 |
17 | 2 | 78 |
Sorry, the site won’t let me post a direct paste from excel yet but this identical to it.