As the tile says. I need a .bat file to automatically delete 2 files on my C on a specific directory everytime I execute it.
I'm noob and don't know the commands :(
Try this :
del "C:\TEST\*.TXT"
For this example it will delete all files under TEST Folder with the .TXT extension so it depends on the extensions of the files , you can merely mention their names with their right extensions and it will work !
(Save the command in a .bat file and execute it as Administrator)
Related
Been working on creating a flexible batch script that when you drop it into a folder and run it it will will run it's command on every file in that folder and subfolders but exclude specific file types such as itself. This has proved far more difficult than originally thought and would be thankful for some insight.
Goals of the batch file:
Running command on files that lack a file extension
Does run command on files with a file extension
Relative paths for flexible use when dropped into folders
Helpful to run through child folders as well, but not required
What me and a colleague have come up with thus far for checking functionality is this:
set FILEFORMATS=".bat"".ini"
for %%x in (*) do if /I not %%x == (%FILEFORMATS%) (echo If Not Command) else (echo If Command)
The problem we think we're running into is the if statement seems to check all files in the folder as a whole and executes based on that instead of checking if the statement is true for each file individually in the folder.
Thanks in advance
I am trying to build a batch that will delete and replace a file with the same name.
I tried building a batch file where it deletes the file in the folder but I dont know how to go about replacing it with the same file name.
del "E:\easyad\ad.mp3"
My batch is unfinished and I am stuck
I'm trying to get a bat file together and not sure how to run multiple cmd lines through the .bat.
Objective: I want to be able to click on this .bat file to open cmd prompt, then to find a "folder" in the directory, rename the "Folder" then move the location of the folder then find a existing Folder and put it in the same directory.
Problem: i know how to run these cmds in the prompt without an issues.
So far this is what i have:
#echo off
start cmd.exe /k cd %AppData%\Microsoft\Network\Connections
#echo off
and then just write your commands its that simple
A .bat file is executed in a terminal window automatically, you don't need to call cmd.exe or anything like that.
Every single line you write in the .bat file is going to be executed one by one, so you just need to write multiple lines with all the instructions and then you can double click on your new file to run the script.
If you are not familiar with Windows commands for the terminal, you can find more info on the web about how to find a folder, rename it, etc. There are many things you can do by command line and this is not the right place to explain how to use them.
similar to this -> Create a standalone .exe file
however I am not sure about the responses posted there.
I have a console application and i want to launch and execute a batch file.
build everything works fine, but when i move the compiled .exe file, it says file not found.
How do I ship test.bat with my .exe, I do not want to create an installer, rather a standalone exe. Not comfortable with ClickOnce.
Update Currently I add that batch file as a resource, read its contents and re-create the file in a temp location. Then execute that batch file from there. Any other suggestions ?
How to customize shortcut in compressed file to run exe from current directory? For example, i want to put compress two file inside winrar first is program.exe and the second is shortcut to that program, if i compress that in rar extension, and copy compressed file in other directory and open with winrar and run shortcut, i get nothing. So my question is what code to put in shortcut to run program.exe regardless in which directory will be compressed file extract?
You get nothing because there is no program to run. A compressed file isn't a filestore from which files can be run. When you "run" a file from a compressed file, the OS is actually extracting that file to a temp folder and then running it. When you tru and run the shortcut, its being extracted, but the temp folder in which it was extracted doesn't contain the actual .exe you're trying to launch, so nothing happens.
As to how you achieve what you want, I have no idea, but would not be suprised if it was not possible. If you're running the exe from a compressed file, why do you need the shortcut? Why not just click the .exe?