Quickest way to create a .bat file (as .txt) - batch-file

I have a couple lines of code in a batch file in Windows 10 that open a session of Octave, and load a script that uses design parameters contained in a .txt file. The batch file is named (for example) "Design123.bat", and when Octave runs, it automatically finds the design parameters in the file "Design123.txt" by simple string manipulation of the file name, i.e. strrep(filename,".bat",".txt"), where filename = '%~dpn0' is passed to Octave from the batch file. This allows for the contents of the batch file to stay simple and constant, and the file name of the batch file is the only thing tying it to the .txt file.
I do all of this to allow running the Octave script by double-clicking the batch file for convenience, instead of being forced to use the more tedious process of uigetfile in Octave. This works very well, but the catch is that I have to place a copy of the batch file in the same directory with the design (.txt) files (of which there are thousands, but each within their own directory) and give it the same file name to get it to work. Is there a way to quickly create the batch files somehow? The most ideal situation I can think of is to be able to right-click (or somehow select) a .txt design file, and create a batch file (replacing .txt with .bat) and place my lines of code into it.
Any ideas? I have coding experience, but only in software packages like VBA and Octave, not within operating systems themselves, though certainly willing to learn if I could get pointed in the right direction. The design file names follow a distinctive pattern, so they could be filtered easily within an operation on the active "File Explorer" window in Windows 10, if something like that is possible. Thanks in advance.

You might want to compose the answer to your question from calling the script on the right click and running the .m script with command line arguments.
If that fails, uigetfile is certainly not the only method to get file. At the very least you could always copypaste a path string to a folder from explorer to octave function call.
Finally, I guess I'll mention the existence of octave-cli which runs in terminal instead of gui. It might be better suited for running non interactive scripts.

Related

Move files into a jar with a .bat script

Just the title. I'm trying to make a .bat file that moves stuff into a .jar, but I have no idea what to do, or even if it's possible. If it's possible, could I be pointed towards the information that would allow me to create such a .bat file? Thanks.
"A .jar file is just a .zip file with a different extension. Use any zip tool that takes command line parameters like WinZip or 7-Zip, and call it from your batch file passing it the right information in the parameters to add the files. Once you pick your utility app, you can read its documentation to find out what parameters it takes and what order they should be in. (Or more easily, you could just open the file in WinZip or 7-Zip and drag and drop the files in using Windows Explorer and save the time and effort.)" - From Ken White, in a comment
Thank you Ken White, for your answer.
While I do agree not using commands is more convenient, I can't automate moving files without commands or code.
This is a valid answer. But for some reason an arbitrary restriction won't let me mark this post as the answer until two days.

excel compare using batch file and then outputs its difference in a single file

Is there an app that can be run in batch file that compares two excel files and then outputs its difference in a single file?
Currently I'm using GUI Tortoise to compare my excel files. But since it is more convenient to use it as a batch, I prefer having batch file.
I have found a free and nice solution as of now. ExcelDiff outputs differences into a htm file. the app itself can compare excel contents folder by folder. really nice because it displays clearly the differences. I'm testing it now and I encountered no problem as of now. So I guess I'll stick with this as of now.

Sync folders with xcopy/batch based on checksum?

I'm trying to make a simple batch for windows that will basically sync two folders, the catch is that the files in the folders can be named arbitrarily and the snyc should be based on the checksum. I've only found information about xcopy that compares the timestamp so I'm wondering if this is possible in a simple matter at all.
Here is the scenario I'm trying to manage, you've got the "Import Folder" containing the files named A_2.bmp and A_3.bmp and the "Target Folder" containing file A_1.bmp.
File A_2.bmp is infact the same file as A_1.bmp, just with a different name and thus should be skipped, A_3.bmp should then be copied over to target folder and icrementally renamed to A_2.bmp.
This probably sounds more like a work for patching software, but I'm looking for a solution that doesn't require building patches all the time and is open for the user (so he can just drop files into the import folder and run it whenever the need arises)
If there is software for such a thing that is free and can be distributed without installing I would also consider this a good option, but I haven't found anything.
I'm thankful for any advice and help on this matter so thank you very much for your time and help!
You have this command line utility :
http://www.microsoft.com/en-us/download/details.aspx?id=11533
You can then make a bat who simply test the checksum of the files

Create a Windows executable (.exe) from Batch and Vbscript

It is asked me to create a Windows executable (.exe) from scripts written in batch and vbscript. unluckily I don't know which tool use to realize that. Therefore Let me ask you some questions which torment my spirit
Is it possible to make a such build?
If it is, could you recommend me some open tools which do that?
To make an exe from bat+vbs, do you think I have to modify the
content of my scripts alot/a little?
Thank in advance for your feedback
Bat2Exe converts batch files including any other files in a certain folder into executables
http://www.bat2exe.net
"ExeScript Editor" can convert batch files under .bat and .cmd also it can convert .vbs and .vbscript file into a .exe
http://www.scriptcode.com/vbscripteditor/
What you want to do is:
First : Join the bat files and vbs files together in one file.
Second: "Make" a executable of that file to launch the main bat file.
Bat/VBS file can't be compiled, when you see a "compiled bat" it's only a simple .exe stub, the bat is not compiled neither converted, is only stored, so first you need to use a joiner and second you need to use a bat-2-exe "converter" like "ExeScript Editor", searching for the crack in Google to evaluate the program is not hard, I have it.
...But really the best you can do is to use WinRAR application with the SFX options which can join files (compress), make the exe, and can launch the main bat file after silent extraction.
PS: Really the best you can do is to learn the basic things of a real lenguage, embbed the bat/vbs files as resources and then compile it into a standalone executable.

Batch file to list and copy files to another directory

I'm a novice with batch files, even though I've had a computer since the mid 1980s. I need to create a (preferably simple) batch file that will list all the directories on drive D:\TAR\ (to a text file maybe?) and append the extension .tar to the directories names. Then I would like to copy all the .tar files(in the text file that was created) on E:\Incomplete\File1.tar to F:\ToComplete\ directory.
I tried doing it from a DOS command prompt, but I couldn't figure out how to put the .tar extension on the directory names and do the copying. I've been googleing, and searching on this site, with no similar problems.
Is there a list on the net that list most of the commands that can be used in .bat files, for example #echo, end, if, then, etc.? I would like to be able have it as a guide. I would appreciate any and all help.
Thank You.
The command prompt has a builtin help command that provides a decent listing of common commands, and each command supports the /? switch to attain more information on it.
You will typically use the for command to enumerate the contents of a directory, and if you need to perform string manipulation on the directory entries you will probably find the command prompt's "delayed expansion" feature useful. This feature is off by default, but can be enabled for an interactive session by running cmd /v:on. (Enabling this feature permanently requires a registry setting.)
In terms of your specific problem here, when you say "all the directories under D:\TAR\", would that be a recursive operation?

Resources