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!
Batch file to copy and rename file with ipaddress.extension
Moderator: DosItHelp
-
- Posts: 1
- Joined: 21 Sep 2018 04:41
Re: Batch file to copy and rename file with ipaddress.extension
Try
The IP address is assigned to %%j in this example.
Steffen
Code: Select all
for /f "delims=: tokens=2" %%i in ('ipconfig^|findstr "\<IPv4"') do for /f "tokens=*" %%j in ("%%i") do copy "Expeditool.accdb" "Expeditool%%j.accdb"
Steffen
Re: Batch file to copy and rename file with ipaddress.extension
Systems can have multiple ethernet cards and thus multiple IP addresses but usually only a single gateway. If you don't want to run the risk receiving an invalid IP or one that is not assigned a gateway and thus cannot be used to access the internet then you should filter gateway first && then IP.