Read File Names in directory and subdirectory - file

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"

Related

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

xpdf batch file: how to change file name?

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"

Batch to search file name on workstation and to create a txt or docx output

I am looking to create a batch file to search one of my workstations for a specific file by name. If the file is found I want to output the report into a txt or docx.
Below is what I have so far but it is only searching the root directory:
#echo off
C:
if exist C:\test.* (echo FILE_EXIST) else (echo FILE DOES NOT EXIST)
pause
Can someone please provide me with a sample of the batch that I need to make this work? Thank you
That's simple i suppose using dir
#echo off
C:
dir /s/b test.*
pause
It will show file not found if there is no file with the name and will show the complete path of the file where the file(s) with that name is/are.
If you want the reports to be stored in a file use dir /s/b test.* >reports.txt instead.
The reports then will be stored in the file "reports.txt" in the very directory.

Print all the files inside a dir through batch file

I want to write a batch file in DOS which reads all the files from the input directory and display the list of files on the screen using FOR loop.
dir for the files in the directory
dir /s if you want to include the files in the sub-directories.
microsoft command line reference
edit:
FOR %%i IN (*.*) DO echo %%i
This will print out the names of all the files in the directory you run the batch file in.

How to append filename to current directory in Batch file?

I want to search a file in the current directory from which the batch is running, append the filename to the directory and include that entire directory as part of command that.
So.....
Directory:
C:\tempfiles\batch
Files in C:\tempfiles\batch
tmp1.txt
tmp2.txt
tmp3.txt
anyname.exe
I want the batch file, run from the directory, to find any .exe file and append it to the directory name, and use that new string as part of a command to copy the .exe file over to another directory. The command will eventually read like this (the FILETRANSFERSW.exe is the file transfer software that is also in the directory):
C:\tempfiled\batch> FILETRANSFERSW.exe "%CD%\tmp4.exe" X:\dest
The .exe file name will be changing so i need to dynamically add the new filename into the above command everytime i run the batch file. Any ideas??
If I read your problem correctly, is it sufficient to use the "for" keyword?
for %a in (*.exe) do FILETRANSFERSW.exe %a X:\dest
You can test the output with something innocuous like:
for %a in (*.exe) do echo [[%a]]
%a ends up iterating over *.exe in the current directory, returning the full file name for each one.

Resources