0

I have 2,300 text files with filenames that currently do not include the information needed, but must continue to retain their existing file name after I append content from the text files to the names. The text file content is structured and the code should grab the following content out and append to the existing filename.

Short Name = John Doe

I only want John Doe to be pulled from the content and appended to the file name. All the existing file names are unique and should remain the same, I'm just appending whatever is after "=" to the file name.

All the existing questions involve renaming the existing file, appending non-changing text to file names, or some variation thereof. It'd be great if I could have the files go into a separate directory after appending, but not required (I'll be working off copies anyway). Somehow no one is keeping the existing file name and appending content!

How to Batch Append Filename to TXT Contents, Name Output File Based on Original Input Filename, and Loop Through 200,000 Input Files

Renaming file based on its content using Batch file

How to Append to existing file name within a batch command in a for loop

@echo off
setlocal
for /F "tokens=2 delims==" %%a in ('findstr /I "LastLogedUser=" something.txt') do set "uniuser=%%a"  
echo User is: %uniuser%   
copy fpr_log.txt "c:\fpr_log%uniuser%.txt"
endlocal

@echo off
for %%a in (*.txt) do type append_me >> %%a

I found the code above, but the problem is it doesn't append and I only found a snippet of append code.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
  • "Content" is a broad term. You would probably get better replies if you listed sample input and expected output. Is it possible that "LastLoged user" appears more than once in the input file? What to do in that case? Is "LastLogedUser" correctly misspelled? – RGuggisberg Jun 05 '19 at 02:48
  • You say "must continue to retain their existing file name" and then "I only want John Doe to be pulled from the content and appended to the file name." If you want The extracted name to be appended to the existing filename, then you can't "continue to retain" the filename. – Magoo Jun 05 '19 at 03:10
  • Your question makes no sense, you state that you're wanting to rename 2300 text files by appending a string contained within them to their name. So this assumes you're wanting to rename, for example: `something.txt` to `something John Doe.txt`. What therefore is `fpr_log.txt` and how does it relate to the task? – Compo Jun 05 '19 at 11:40
  • Am I able to append the content of a text file with the existing name of the file, then rename the file based on two rows within the text file? The code I presented is a copy of other users' code that they used. I'm not a coder by trade so I'm attempting to get help on how I could keep the existing filename, then append that filename based on a content within the text file. I'm open to whatever method can do this. – SanDiegoGuy Jun 05 '19 at 18:34

0 Answers0