Im trying to close a file (not an application) ussing batch. I namely need particular files and folders closed to execute a delete option. i have noted that open files and folders will not delete.
If you are on a Windows environment, there are a lot of utilities to do that. See for example http://www.thefreecountry.com/utilities/deletelockedfiles.shtml
Related
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.
New to batch file writing. We are unable to install a file renamer program at work so i am looking to find a way to create a batch file to do the job instead. I want to create a batch file that i can place in a folder and it will rename all files in that folder with a prefix, while deleting some text from the file name itself. I am happy to edit the prefix text (as it changes all the time) in Notepad each time but I need to be able to move the batch file to the different folders.
The files will be something like this RDS_117856.pdf
and they need to read as xxx-xxx-xxx-117856.pdf
Any help would be great.
I am using windows, only have access to Notepad and no other coding software so a .BAT file would be the easiest thing to create here.
I have a legacy system that was developed years ago which receives and processes xml files. After processing the file the filename is changed from .xml to ."done" including the quotation marks. I need to write a batch file that will archive these ."done" files on a regular basis but don't seem to be able to get it to work using;
7z a archivename.zip *."done"
which creates the archive file but it is empty. I've tried specifying the files to archive with a few different variations without success.
I need to update an exe file on a daily basis, did create a batch file and used the 'fc' command which worked like a charm but i have two issues.
1) The newer version of the exe file would be located on an FTP site
2) The location of the older exe file would not be fixed.
The older exe file is a single executable and the problem is the user can save it anywhere, need a command so that i can locate that file compare it with the file on the FTP site and update that file if needed.
I am new to this, any help is greatly appreciated.
well you can avoid all of this by using a briefcase then put the file that you want to update into the briefcase and then run the update manually.
but if you really want to do it with a batch file then
#echo off
cls
replace (file being updated) (updated file)
exit
When I create a zip file using SharpZipLib I end up with .tmp files litering my hard drive. It occurs when I add files to an archive.
I'm not too concerned that it's happening, but I'd like to be able to get the file name so that I can remove the files once the archive is completed. How do I get the name of the .tmp file?
Are you closing the zip file you are creating? I use SharpZipLib for several apps and the .tmp file is always cleaned up automatically by the process once the newly generated zip file is closed and released by the process in every one of my apps.
I'm switching to a different library.