Batch File - Can you search a .csv and paste ??
Moderator: DosItHelp
Batch File - Can you search a .csv and paste ??
Hello,
I am a little stuck making a batch file for work. The intention of this batch is to change the status of something on a web based form. I have managed to build the menu, sort the GOTO part and then have the user input a prefix, the next part is highlighted in red below, i would like to be able to copy a cell (A1 is fine) in a .csv file and set it as a variable. Is this possible?
:: UnreportBatchFile MM
@echo off
title Unreporting/Assigning Assitance
echo.
echo --------------------------------------------------------------------------
echo This batch file is used to unreport your exams or assign
echo to a specific radiologist
echo --------------------------------------------------------------------------
:MENU
echo.
echo 1 - Unreport Exams
echo 2 - Assign Exams
echo x - Exit
echo.
set /P M=Type 1 or 2 then press ENTER....
if %M%==1 GOTO PREFIX
if %M%==2 GOTO ASSIGN
if %M%==x exit
cls
echo Sorry,'%M%' is not recognised. Please try again...
echo.
goto MENU
REFIX
set /P prefix=Please enter the sites prefix:
:IMS
start chrome.exe http://website=%prefix%-%NEED TO COPY AND PASTE FROM CSV%&op=exams
pause > nul
:ASSIGN
I am a little stuck making a batch file for work. The intention of this batch is to change the status of something on a web based form. I have managed to build the menu, sort the GOTO part and then have the user input a prefix, the next part is highlighted in red below, i would like to be able to copy a cell (A1 is fine) in a .csv file and set it as a variable. Is this possible?
:: UnreportBatchFile MM
@echo off
title Unreporting/Assigning Assitance
echo.
echo --------------------------------------------------------------------------
echo This batch file is used to unreport your exams or assign
echo to a specific radiologist
echo --------------------------------------------------------------------------
:MENU
echo.
echo 1 - Unreport Exams
echo 2 - Assign Exams
echo x - Exit
echo.
set /P M=Type 1 or 2 then press ENTER....
if %M%==1 GOTO PREFIX
if %M%==2 GOTO ASSIGN
if %M%==x exit
cls
echo Sorry,'%M%' is not recognised. Please try again...
echo.
goto MENU
REFIX
set /P prefix=Please enter the sites prefix:
:IMS
start chrome.exe http://website=%prefix%-%NEED TO COPY AND PASTE FROM CSV%&op=exams
pause > nul
:ASSIGN
Re: Batch File - Can you search a .csv and paste ??
I can easily pull the information from a .txt file it if is easier?
There would be a list of ids such as:
abc123
abc1234
acb324
Is there anything anyone can think of? I basically would like to copy for example abc123 and then paste it into the address bar in the appropriate place
There would be a list of ids such as:
abc123
abc1234
acb324
Is there anything anyone can think of? I basically would like to copy for example abc123 and then paste it into the address bar in the appropriate place
Re: Batch File - Can you search a .csv and paste ??
set /p id=<ID.txt
Re: Batch File - Can you search a .csv and paste ??
That works a treat Squashman
that only reads the first line right?
If that is true (which is what it is doing now) then how would you suggest i coded it to do the same thing for sake of a number 5 IDs. Would i have to have a separate text file for each id?
that only reads the first line right?
If that is true (which is what it is doing now) then how would you suggest i coded it to do the same thing for sake of a number 5 IDs. Would i have to have a separate text file for each id?
Re: Batch File - Can you search a .csv and paste ??
This can be done with a csv file as well. So if the id is the first variable in your csv.
%%G is the variable you use for the ID.
Code: Select all
for /f "tokens=1* delims=," %%G in (ID.csv) do (
Start chrome ......
)
%%G is the variable you use for the ID.
Re: Batch File - Can you search a .csv and paste ??
Matt20687 wrote:how would you suggest i coded it to do the same thing for sake of a number 5 IDs
This variation of Squashman's code will work if you want to use every line in the text file.
Code: Select all
for /f "delims=" %%G in (ID.csv) do (
Start chrome ......
)
Re: Batch File - Can you search a .csv and paste ??
It seems to be following the logic but not working properly. The script has recognised there are 4 ids within the .csv and opens 4 seperate tabs on google chrome with the correct link and such like, the only problem is is that it is only copying and pasting the first id in the list of 4, therefore every tab (4 in total) is showing as the same one.
My script is:
: PREFIX
echo.
set /P prefix=Please enter the sites prefix:
:SITE
set dst=c:\users\matthewm\desktop\unreport or assign batch\
set dst2=c:\users\matthewm\desktop\unreport or assign batch\
set /p texte=<unreportid.csv
for /f "tokens=1* delims=," %%G in (unreportid.csv) do (
start chrome.exe "http://WEBSITE=%prefix%-%texte%&op=exams"
)
My script is:
: PREFIX
echo.
set /P prefix=Please enter the sites prefix:
:SITE
set dst=c:\users\matthewm\desktop\unreport or assign batch\
set dst2=c:\users\matthewm\desktop\unreport or assign batch\
set /p texte=<unreportid.csv
for /f "tokens=1* delims=," %%G in (unreportid.csv) do (
start chrome.exe "http://WEBSITE=%prefix%-%texte%&op=exams"
)
Re: Batch File - Can you search a .csv and paste ??
Would it be the delimiter causing issues?
Re: Batch File - Can you search a .csv and paste ??
Try the change below. It expects to use the first four fields in the CSV file, which are delimited by comma
Matt20687 wrote:My script is:
: PREFIX
echo.
set /P prefix=Please enter the sites prefix:
:SITE
set dst=c:\users\matthewm\desktop\unreport or assign batch\
set dst2=c:\users\matthewm\desktop\unreport or assign batch\
for /f "tokens=1-4 delims=," %%a in (unreportid.csv) do (
start "" chrome.exe "http://WEBSITE=%prefix%-%%a&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%%b&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%%c&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%%d&op=exams"
goto :next
)
:next
Re: Batch File - Can you search a .csv and paste ??
It still is doing the same thing foxidrive. It is searching for each one (4 in total) but again it is using the same ID rather than the 4 separate ones.
My code is:
set /p uid=<unreportid.csv
for /f "tokens=1-4 delims=," %%a in (unreportid.csv) do (
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
goto :next
)
:next
:next
My code is:
set /p uid=<unreportid.csv
for /f "tokens=1-4 delims=," %%a in (unreportid.csv) do (
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
goto :next
)
:next
:next
Re: Batch File - Can you search a .csv and paste ??
Hello,
I am tearing my hair out over this!! Cannot figure out why it will read all of the entries but not copy/paste any but the first one!
Is there anything anyone can suggest as its holding my whole project up now, i will keep looking but i have been trying to sort it for hours now so not too full of hope
Thanks for everything everyone,
Matt
I am tearing my hair out over this!! Cannot figure out why it will read all of the entries but not copy/paste any but the first one!
Is there anything anyone can suggest as its holding my whole project up now, i will keep looking but i have been trying to sort it for hours now so not too full of hope
Thanks for everything everyone,
Matt
Re: Batch File - Can you search a .csv and paste ??
Matt20687 wrote:It still is doing the same thing foxidrive.
My code is:
set /p uid=<unreportid.csv
for /f "tokens=1-4 delims=," %%a in (unreportid.csv) do (
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
goto :next
)
:next
Your code doesn't use %%a and %%b and %%c and %%d
Re: Batch File - Can you search a .csv and paste ??
foxidrive wrote:Matt20687 wrote:It still is doing the same thing foxidrive.
My code is:
set /p uid=<unreportid.csv
for /f "tokens=1-4 delims=," %%a in (unreportid.csv) do (
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
start "" chrome.exe "http://WEBSITE=%prefix%-%uid%&old_patient_id=%prefix%-%uid%&op=exams"
goto :next
)
:next
Your code doesn't use %%a and %%b and %%c and %%d
You will have to forgive me, i havent been doing this long!! So are you saying the first line should read:
for /f "tokens=1-4 delims=," %%a %%b %%c %%d in (unreportid.csv) do (
Re: Batch File - Can you search a .csv and paste ??
Nope. Examine the code I provided, based upon your example above.
Re: Batch File - Can you search a .csv and paste ??
Remember in my example when I told you %%G is the variable you need to use for the ID.
Are you putting all the ids on one line separated by a comma or is this a true csv file and the id is the first field in each line.
Could we see the id file please.
Are you putting all the ids on one line separated by a comma or is this a true csv file and the id is the first field in each line.
Could we see the id file please.