Solved Rename .csv Files based on its content

November 13, 2015 at 02:35:44
Specs: Windows 64, i7
Hi community!

is it possible to rename all *.csv files in a directory with content from the file itself?

Here is an example of one File:


I want to get the Second value of the second Line (1105) and append it to the filename. "Zst" is in every line the same in one file.

export-345.csv --> export-345-zst1105.csv
export-345.csv --> export-345-zst3452.csv

I don't have much batch-scripting know-how, is it possible?


See More: Rename .csv Files based on its content

Report •

November 13, 2015 at 05:57:48
✔ Best Answer
@echo off
for %%i in (*.csv) do call :REN "%%i"
del *.csv
ren *.new *.csv
goto :EOF

for /F "skip=1 tokens=2 delims=;" %%j in ('type "%~1"') do (
  copy "%~1" "" > nul & goto :EOF)

Report •
Related Solutions

Ask Question