First time doing batch files, I don't even know how to do it. I need a batch file that given a path (say I:\FOLDER1\SUBFOLDER1\) will produce a text file showing all the subfolders in that directory as fully qualified paths.
Something like this:
I:\FOLDER1\SUBFOLDER1\SUBSUBFOLDER1
I:\FOLDER1\SUBFOLDER1\SUBSUBFOLDER2
I:\FOLDER1\SUBFOLDER1\SUBSUBFOLDER3
I:\FOLDER1\SUBFOLDER1\SUBSUBFOLDER4
...
If understand you are trying to list file path
dir/s/b *.txt
to redirect it into a text file
dir/s/b *.txt > textfile.txt
Help full Link
Related
While executing a batch file it only adds files to its own directory, I wanted to make it so that it makes the new TXT file to a specified location
echo You are very good > you.txt
This just makes a text file in the same Dir as the batch file, how would I make it so that it makes the txt file into a specific location
You can easily specify the full path like this:
echo You are very good >"YOUR FULL FILE PATH HERE LIKE C:\MYFOLDER\you.txt"
I have a batch file which currently output a log file by calling its extension
(sqlplus #Down.sql "test" "testl") > "%~dpn0.log"
which outputs the log file to the same location of the batch folder.
e.g. C:\Folder1\run.bat
of course, the log file would be run.log
I would like to output the log file to a log folder.
similar to C:\Folder1\log\run.log.
Anyhelp is appreciated in pointing out hwo to do it in my source code. Thanks
...> "c:\folder1\log\%~n0.log"
should suffice. The trick is the %0 means the name of the batch, and this can be mofified by ~letters which may be used in any combination.
The letters that are significant are listed conveniently in the for documentation, accessible from
for /?
executed from the prompt.
I am working on a batch file right now and I have everything done that I need but I'm stuck at one point. One of the programs I use spits out a log file and I have it place this file on the C:drive in a folder. What I want to do is have it read this .txt and spit that back into the batch file as an echo.
You can put this in your batch file:
type C:\folder\test.txt
This will echo out the contents of test.txt.
Edit: Brief Summary
I have number files in a directory, called crash0, crash1 etc. I want to run a .bat file for each of this with a command line like:
abc.bat crash0 > crash0.txt
How can I make another .bat file that loops over all the crashXX files calls abc.bat once for each one of them?
Original Question
Please find my situation below..
I have some files (number may vary each time) in a folder with its name starting with crash. That is crash0, crash1..etc. I want to provide these files as an input to a .bat file (let it be abc.bat) and then navigate the out put a corresponding text file. The command looks like abc.bat crash0 > crash0.txt. I have to do this to all the crash files in the folder. This abc.bat files actually converts the non-readable files to a readable format. So at the end I should have txt files like crash0.txt, crash1.txt.. etc for the corresponding crash files which i provided as the input. Can any one help with a .bat script to run this in cmd?? am new to .bat scripting.. thx in advance
for %%i in (crash*) do #call abc.bat %%i > %%i.txt
I'm trying to copy a number of files from a directory. I want to include the file path from the base of this particular directory tree, however, I only have a list of the file names to go by. Is there a way to copy either:
a list of files with their directories appended to the beginning in a .txt file
a copy of the folders in the directory with copies of the files placed in their original places in the original directory.
Each file in the directory has a unique name.
I've looked all over google, but the closest I've found is xcopy, which I don't believe is capable of this.
Thanks!
For the second option you can use xcopy /s or robocopy /s. Both are great tools for this kind of job.