Click here for important information about

Copy PDF template and rename it using user input

March 29, 2012 at 09:55:59
Specs: Windows 7
I am attempting to copy a PDF template into a specific folder, rename it according to the user's input (it will be the name of a patient) and be sure that if it already exists that a number is attached to the name. (Lastname_Firstname1, Lastname_firstname2, etc) Then open the created file.

Is this possible?

See More: Copy PDF template and rename it using user input

April 1, 2012 at 08:34:45
@echo off
set loca=C:\myfolder
set CHOICE=?
set /P CHOICE=Enter file's name and file extension
IF EXIST "%loca%\%CHOICE%" (
echo f | xcopy "myfile.txt" "%loca%\%CHOICE%1" /s /q
) else (
echo f | xcopy "myfile.txt" "%loca%\%CHOICE%" /s /q
Downside is this will only work up to 2 duplicate files. Need someone more experienced to modify that and it should be alright.

Report •

April 3, 2012 at 15:51:24
This is what I ended up with. Took some research online and otherwise, but it works like a charm. :)

@echo off
REM This will copy theTemplate
REM and save it as the patient's name.

:User Input
copy f:\centennial.pdf f:\centennial\centennial.pdf
echo Enter the patient's last name.
set /p "lastname=>"
echo Enter the patient's first name.
set /p "firstname=>"

set NAME=%lastname%_%firstname%
Set FILE=0

set /a VAR=%ANVAR% + 1
set /a NUM= %FILE% + %VAR%
If exist f:\centennial\%NAME%%NUM%.pdf goto LOOP
REN f:\centennial\centennial.pdf %NAME%%NUM%.pdf
start f:\centennial\%NAME%%NUM%.pdf

Report •
Related Solutions

Ask Question