Link to home
Create AccountLog in
Avatar of alam747
alam747

asked on

How to read all PDF files in a specific directory and write the fiile names to a text file

Please advice me how to retrieve files from a specific directory and write them to a text file.

for example: I have 5 .pdf files under C:temp want to make a text file name filelist.txt which would be like that......
"a.pdf"
"b.pdf"
"c.pdf"
"e:pdf"
Please advice me any easy VBA code for this purpose with all definitions where necessary.
Thanks in advance for your co-operation.
Avatar of Dale Harris
Dale Harris
Flag of United States of America image

You could easily do this in Powershell:

get-childitem "*.pdf" | ft "name" > Filelist.txt

HTH,

Dale Harris
Oops, you'd need to specify which directory to look in, so use this command instead:

get-childitem "C:\Temp" "*.pdf" | ft "name" > Filelist.txt

Dale Harris
Avatar of alam747
alam747

ASKER

Actually I wanted to add in my VBA code, please advice does it work in VBA code if so if there anything need to be defined to use it.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of SiddharthRout
SiddharthRout
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of alam747

ASKER

Thanks a lot