I'm not too familiar with batch files. Most commonly I use VBA/PHP, but I would like to have this one a go :).

I would like to:

Fetch the user's IP address, Copy a file, and rename that file to ipadres.extension

So the new file name should be the IP.

for example:

ipconfig | find "IPv4"
copy /y Expeditool.accdb Expeditool"IPv4".accdb

I tried, but just puts IPv4 in file name.

Could anyone help me out with this one? Thanks!


A dirty example to get your IP:

for /f "tokens=14" %%a in ('ipconfig ^| findstr IPv4') do set _IPaddr=%%a
echo IP is: %_IPaddr%

You then use %_IPaddr% in your copy /y Expeditool.accdb Expeditool"IPv4".accdb


for /f "tokens=14" %%a in ('ipconfig ^| findstr IPv4') do set _IPaddr=%%a
copy /y Expeditool.accdb Expeditool%_IPaddr%.accdb

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.