I have multiple .pdf
files located in one directory.
Example of the file names in the directory :
test score_test score _9999999999_smith.pdf`.
I need to parse the file name to be: 9999999999|test score|smith|||||||
And I also need to print the location of the file to a text file with an @
symbol at the beginning.
So it looks like this in the text file: @D:\\TEMP\\test score_test score _9999999999_smith.pdf
The file output in the text file would be:
9999999999|test score|smith||||||| @D:\\TEMP\\test score_test score _9999999999_smith.pdf
I only got to as far as outputting the directory and file name to a text file.
Right now I'm just working on adding the @
to the beginning of the directory/filename.
dir /s/b *.pdf > C:\temp\test.txt
I've tried this:
@echo off
set var1=@
dir *.pdf /b /s DO ECHO %var1%*.pdf > C:\temp\test.txt
I've tried this:
dir *.pdf /b /s ren *.pdf "@"????????????????????????????????????????????????????????.pdf >> C:\temp\test.txt
@Echo off&SetLocal EnableExtensions
PushD "C:\path\to\your\pdffolder"
Set "FileOut=X:\path\to\LogFile.txt"
:: initially clear Logfile
Type Nul >"%FileOut%"
:: first for enumerates the pdfs, second for /f parses the name
:: to tokens %%A .. %%D delimited by underscore
For %%F in (*.pdf) do For /f "tokens=1-4 delims=_" %%A in ("%%~nF"
) Do (
>>"%FileOut%" Echo:%%C^|%%B^|%%D^|^|^|^|^|^|^|
>>"%FileOut%" Echo:@%%F
)
Sample LogFile.txt
8888888888|test score |miller|||||||
@test score_test score _8888888888_miller.pdf
9999999999|test score |smith|||||||
@test score_test score _9999999999_smith.pdf
7777777777|test score |baker|||||||
@test score_test score _7777777777_baker.pdf
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.