Batch inserting characters in file names using ren in windows
I would like to batch rename file names inserting 4 characters ("Lna_") within the fine name as:
Cdt001_10x_G75_01s_Ft1.tif -> Cdt001_10x_G75_01s_Lna_Ft1.tif ,
Cdt001_10x_G75_01s_Ft2.tif -> Cdt001_10x_G75_01s_Lna_Ft2.tif ,
Cdt001_10x_G75_01s_Ft3.tif -> Cdt001_10x_G75_01s_Lna_Ft3.tif ,
...
Is it possible? Thanks
Split the names at the underscores with a parsing for /f
and insert _LNA
behind the 4th token.
In cmd line
for %A in (*_*_*_*_*.tif) do @for /f "tokens=1-4* delims=_" %B in ("%A") Do @echo Ren "%A" "%B_%C_%D_%E_LNA_%F"
If the sample output
Ren "Cdt001_10x_G75_01s_Ft1.tif" "Cdt001_10x_G75_01s_LNA_Ft1.tif"
Ren "Cdt001_10x_G75_01s_Ft2.tif" "Cdt001_10x_G75_01s_LNA_Ft2.tif"
Ren "Cdt001_10x_G75_01s_Ft3.tif" "Cdt001_10x_G75_01s_LNA_Ft3.tif"
looks OK remove the echo in front of ren.
In a batch file double all the percent signs.