I need to rename portions of a number of files while keeping the IP address that's in the filenames.For example,Abc_192.168.1.164_001.txtAbc_10.11.76.112_001.txtAbc_54.78.1.1_002.txtI need to keep the Abc_ portion as well as the IP address. Everything after is to be replaced with a date and time stamp.  I would be adding the current date and time stamp as _yymmdd-yymmdd-hhmmss and we will be changing the extension to .csv. This will run on Linux.
Renaming files while keeping portions
files;rename
Here's a simple shell loop to (carefully) rename the files as I think you're asking:d=$(date +%y%m%d-%y%m%d-%H%M%S)for f in Abc_*.*.*.*_*.txtdo  new=${f%_*}_${d}.csv  [ ! -f $new ] && mv $f $newdoneIt first captures the timestamp, in the format you wrote, into a variable named d. It then loops over a simplistic glob format to pick up all files whose name starts with Abc_ and then have anything between the three periods, followed by anything, then followed by an underscore and anything, and ending in .txt.It computes the new filename by stripping off everything (including and) after the last underscore, then appends the timestamp (${d}) and the new .csv extension.If that new filename does not exist, then it will rename the file. Remove the [ ! -f $new ] && part if you don't care about clobbering existing files.Add in an echo before the mv if you want to see a dry-run of what it would do before actually executing it.When I run it, I see:$ touch Abc_10.11.76.112_001.txt Abc_192.168.1.164_001.txt Abc_54.78.1.1_002.txt$ d=$(date +%y%m%d-%y%m%d-%H%M%S)$ for f in Abc_*.*.*.*_*.txt; do new=${f%_*}_${d}.csv; [ ! -f $new ] && mv $f $new; done$ ls -1Abc_10.11.76.112_160913-160913-140649.csvAbc_192.168.1.164_160913-160913-140649.csvAbc_54.78.1.1_160913-160913-140649.csv