from a filename to file paths
from a filename to file paths
Hi
I have a txt containing a list of document names (docx) For example:
newdoc2023.docx
document_34.docx
filedocument.docx
I would need a script that searches the list of names inside a folder (and subfolders) and creates a txt containing the file path
For example:
C:\Doc\Nuova cartella\2023\newdoc2023.docx
C:\Doc\Nuova cartella\2020\base\doc\document_34.docx
C:\Doc\archive\2021\save\filedocument.docx
Many thanks
P.S. I apologize for posting this (I assume) in the wrong section
I have a txt containing a list of document names (docx) For example:
newdoc2023.docx
document_34.docx
filedocument.docx
I would need a script that searches the list of names inside a folder (and subfolders) and creates a txt containing the file path
For example:
C:\Doc\Nuova cartella\2023\newdoc2023.docx
C:\Doc\Nuova cartella\2020\base\doc\document_34.docx
C:\Doc\archive\2021\save\filedocument.docx
Many thanks
P.S. I apologize for posting this (I assume) in the wrong section
-
- Posts: 36
- Joined: 2021-Dec-13, 3:53 pm
Re: from a filename to file paths
Code: Select all
dir newdoc2023.docx /s /b >result.txt
Re: from a filename to file paths
thanks but can you tell me exatly where I must put the string?
I m looking for a .bat that execute the operation
And, the filename list is in txt format
I m looking for a .bat that execute the operation
And, the filename list is in txt format
- Simon Sheppard
- Posts: 192
- Joined: 2021-Jul-10, 7:46 pm
- Contact:
Re: from a filename to file paths
If you just have a small number of files, you can do what Simon_Weel suggests and hard code the filenames:
dir newdoc2023.docx /s /b >result.txt
dir document_34.docx /s /b >>result.txt
etc
If you have a lot of files then you will want to automate reading the filenames in a loop:
Thats assuming the current directory is the top of the tree to be searched.
dir newdoc2023.docx /s /b >result.txt
dir document_34.docx /s /b >>result.txt
etc
If you have a lot of files then you will want to automate reading the filenames in a loop:
Code: Select all
@echo off
for /f %%G in ('type files.txt') do call :sub "%%G"
goto:eof
:sub
dir %1 /s /b >>result.txt
Re: from a filename to file paths
thanks but i run the bat and nothing happens
- Simon Sheppard
- Posts: 192
- Joined: 2021-Jul-10, 7:46 pm
- Contact:
Re: from a filename to file paths
You may have to adjust the filenames to match what you have.
Re: from a filename to file paths
I think is correct. The file is named "typefiles.txt"
I have put the file and the bat in E: that is the source folder
And I have edit the script to
@echo off
for /f %%G in ('typefiles.txt') do call :sub "%%G"
goto:eof
:sub
dir %1 /s /b >>result.txt
I have put the file and the bat in E: that is the source folder
And I have edit the script to
@echo off
for /f %%G in ('typefiles.txt') do call :sub "%%G"
goto:eof
:sub
dir %1 /s /b >>result.txt
-
- Posts: 36
- Joined: 2021-Dec-13, 3:53 pm
Re: from a filename to file paths
You have to edit 'typefiles.txt' to include all file names to scan for, like
etc.
If you want to scan for all .docx files, you can use something like
Code: Select all
newdoc2023.docx
document_34.docx
If you want to scan for all .docx files, you can use something like
Code: Select all
dir c:\doc\*.docx /s /b >result.txt
Re: from a filename to file paths
dont work for me
-
- Posts: 36
- Joined: 2021-Dec-13, 3:53 pm
Re: from a filename to file paths
What happens when you run the script?
Can you post the script and the content of 'typefiles.txt'?
Can you post the script and the content of 'typefiles.txt'?