Open a .bat file, out of a folder, off a flashdrive - batch-file

I have a game that I'm making off of my flashdrive, and I'm trying to make a save feature into an RPG game. I know I can just save all the data into a character bat file, and then call that bat file, but the problem is that my flashdrive looks cluttered whenever multiple characters get formed. understand? I need to beable to load a save, from a character folder (for organization) from a changing source folder, (Because the flashdrive will be in different USB ports, such as :E or :F etc.)

You can determine the drive that a Windows batch file uses by using the CMD variable substitutions. Within a batch file, you can determine where the file resides.
%~d0 is the drive. %~dp0 is the directory. And there are more.
See What does %~dp0 mean, and how does it work?

Related

Batch file to Drag and Drop files to convert via FFMPEG

this is probably my first time ever posting on stack overflow.
I have successfully installed and tested ffmpeg.
Now I want to create a batch file where I can drag and drop my .mp4 or .mkv files to convert to .mp3.
I have no experience with ffmpeg or what parameters to use (the test was a copy/paste with the correct file names filled in) and I haven't touched batch scripting in a long time.
Here is the batch script I found online that kind of works but gives me issues.
#echo off
Pushd "Filepath"
for %%a in (*) do (
ffmpeg -i "%%~fa" "%%~na.mp3"
)
pause;
Batch file is stored on usb drive, along with the shortcut to it (also stored in same folder). The reason for the shortcut is to be able to run the batch as admin once a file is dropped in. The mp4 file is also stored on the same usb in the same folder.
Things are starting to get kind of complicated, and a little above my pay grade.
If anybody has solutions please let me know, maybe the batch script I stole off the internet is wrong.

.bat file to open a specific folder and copy files from a usb drive

I am having difficulties with creating a simple batch file.
What I would like is a batch file that will open up a specific directory and copy 2 files from the same directory that the batch file is in and paste them in the directory that was just opened.
So, in this instance, I have a USB flash drive. I have two IE shortcuts that I would like copied and placed in a public desktop.
The .bat file and the 2 files will all be on the root of the flash drive.
So, my understanding is that it should look like this (EWQ is the IE shortcut and keyfinder is just a test file because i wasn't sure on the extensions... i could not figure out what the IE shortcut extension would be as I don't think it has one):
%SystemRoot%\explorer.exe C:\Users\Public\Desktop<br>
copy EWQ C:\Users\Public\Desktop<br>
copy keyfinder.cfg C:\Users\Public\Desktop
I get my public desktop folder to open but nothing copies. I have
tried various prefixes, like "%~dp0\EWQ" (with an without the quotes)
but to no avail.
These will be loaded from a flash drive and I have about 500 to do so I'd like this as quick and possible. Basically, pop in the flash drive, double click the .bat file and yank it out. In theory, it 'should' be the same drive letter every time, but that isn't guaranteed.
Thank you for any help!!!
This is a batch file, let's call it testing.cmd.
#Copy "%~d0\EWQ.url" "%PUBLIC%\Desktop"
#Copy "%~d0\keyfinder.cfg" "%PUBLIC%\Desktop"
Place this file somewhere on your flash drive and double click it, ensuring that both EWQ.url and keyfinder.cfg are in the root of that drive. If you do not have access to the destination you could try by right clicking testing.cmd and choosing Run as administrator.

Batch File Rename - Batch File needs to move from folder to folder

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.

pass execution path of sfx to batch file

So basically i want to wrap my batch file in an sfx to make a tidy package as I am using multiple files that need to be packaged with the batch file. The problem I am facing is that I need drag and drop functionality so I need to somehow pass the file dropped on the sfxz to the batch file via the execution code.
I am using the winrar default sfx module.
So far I have tried passing it with the %~1 variable but that just passes literally %~1 instead of the location of the dropped file
Any help will be appreciated.
You can use BHX from here to encode the binaries into the batch file, so it is just one file to distribute. http://www.dostips.com/forum/viewtopic.php?f=3&t=4104

Copy files automatically from usb to specific folder with specific extensions

I have huge amount of flash drives and I need to backup my files on specific folder (for example C:\Backup).
There are two problems :
1. I need to backup files with .doc and .docx extension only.
2. When flash drive is inserted, I want that files would copy automatically.
(It's loop if I remember)
Is there any batch solution for this?
try this tutorial for autoplay USB
Then, i am thinking, instead of the autoplay.exe you can set it to run a batch file instead.
In that batch file use the xcopy command.

Resources