xpdf batch file: how to change file name? - batch-file

I'm using a simple batch file calling the xpdf engine to convert a PDF to a TXT file. Right now, the resulting txt file's name is the same as the PDF's, except the extension has been changed to .txt of course. However, I want to add some text behind the original file name, how can I do this? For example, if there's a PDF called test.pdf, it should be converted to text and stored in a txt file called testFULL.txt.
This is the current batch file I have:
for /R %%s in (*.pdf) do "C:\xpdf\bin32\pdftotext" -raw "%%s"

Based on the comment showing that the output text file is a parameter:
for /R %%s in (*.pdf) do "C:\xpdf\bin32\pdftotext" -raw "%%s" "%%~dpnsFULL.txt"

Related

How to insert text into multiple text files using a .bat file?

I having drouble to create a batch file that can insert text into multiple text files at once.
What I can do just now is that one file that I drop on the batch file is getting inserted with the text "I AM PROGRAMMING".
But I would like to drag multiple text files and that all of it/each every text file gets inserted with that text.
#echo off
echo I AM PROGRAMMING> "%~1"
Or if there is somehow possible to do so every text file in a specific place/folder gets inserted with a specific text (for example "I AM PROGRAMMING")?
Your solution processes each matching file in the folder, but you said I would like to drag multiple text files.
It's easy to process "multiple dragged files": %* is "all parameters". Just use a plain for loop to process each of them:
#echo off
for %%a in (%*) do echo I AM PROGRAMMING> "%%~a"
(note that this overwrites the files with the one new line; if you want to append, use >> instead of >)
In case you want to process "all .txt files in the folder of the one file I dragged":
for %%a in ("%~dp1\*.txt") do ...
Or "all files in the same folder of the one file I dragged and the same extension as the dragged file":
for %%a in ("%~dp1*%~x1") do ...
I found my solution!
#echo off
cd "yourfilepath"
for %%a in (*.txt) do (echo I AM PROGRAMMING> %%a)
I merged these two helpful information.
How can I use a batch file to write to a text file?
And
Append multiple files using a .bat

Create folders and files from txt batch script

I've already found most of the answers, but I still can't use the batch file to create what I need.
I need to create folders according to the list in folders.txt.
Create an item.cs.md file in the folders.
Write the content from the content.txt file to the file one by one.
Folders are already creating me files as well, but the content is always filled with just the one from the underline content.txt line.
#echo off
SETLOCAL
for /f "delims=" %%l in (content.txt) do (
for /f "tokens=1" %%a in (folders.txt) do (
if not exist "%%a" mkdir "%%a"
ECHO %%l>%%a\item.cs.md
))
Thanks for your time and tips.
Documentation:
How to create multiple text files each with different names using a batch file?
create folders from each line of a textfile in bat
How to create folders and files from text file with same names to insert with corresponding name?
Batch File To Copy Every Line In .txt File And Then Create New .txt File For Each Line

Appending content of batch to file to existing file name

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.

Read File Names in directory and subdirectory

I have scenario where I need to find out all .csv file in current directory and sub directory and execute below command where .csv file name will be replaced dynamically which will convert in .txt (From Comma delimited to tab delimited file).
I have convertme.vbs file which takes from file and to file name as parameter which converts file but not sure how to achieve for all files in directory and sub directory.
Below is sample command I need to execute in batch file but need batch code which will read file names and plug into below command.
cscript convertme.vbs From_CSV_FileName.csv From_CSV_FileName.txt
convertall.bat
FOR /R %%G in (*.csv) do cscript //nologo convertme.vbs "%%~G" "%%~dpnG.txt"

Batch Check for Same Name in folder And Replace it with that

IF inside my .txt file called named.txt has the following text in them.
2005060.png “3/1/2005”
The 2005060 is a parse text that came from A2005060SAMPLE.png. Is there a way to create a batch file to check the folder the same folder where the .png are located and revert back to their original name while leaving dates such as “3/1/2005” next to it intact.
For example: name.txt file has
2005060.png “3/1/2005
2005070.png “3/11/2005
2005080.png “3/21/2005
2005090.png “3/31/2005
The batch file will check for a piece of 2005060 in the same folder and find that there is one but named A2005060SAMPLE.png as a name and replace it will that one and output to name2.txt
A2005060SAMPLE.png “3/1/2005
A2005070SAMPLE.png “3/11/2005
A2005080SAMPLE.png “3/21/2005
A2005090SAMPLE.png “3/31/2005
Thanks for anyhelp in this!!! :)
How about:
#echo off
for /f "tokens=1,2* delims=. " %%i in (named.txt) do (
for %%m in (*%%i*) do echo %%~nxm %%k >> outfile.txt
)

Resources