batch rename files using a user specified variable - batch-file

I am wondering if it is possible to rename folders, the contained sub-folders, and contained files using a prompted user specified variable?

Related

Using command to find DIR name within USER folder

Im creating a .bat file to copy over a folder from the current directory into the USERS/???/AppData/Local/CourseWork/ folder
However there is no way of knowing what the name of the ??? folder will be as it will be a random students computer.
Is there any way Using Command (and my BAT file) To either retrieve said Folder name , Or copy the files into the Coursework Folder without knowing the ??? folder name.
i was hoping it would be as simple as
copy "Test.exe" "C:\USERS\ . \APPDATA\LOCAL\test.exe"
but unfortunatly it is not.
Iv also looked at Xcopy and robocopy but found no solution , not that there is no solution, i just have not yet found it...
Does anybody have any idea how they would work around this
My .bat file works fine for 1 set of folders & files but once it comes time for this particular folder (C:/USERS/???/APPDATA/LOCAL/COURSEWORK/), im very stuck on what to do for not knowing the name of the ??? folder or how to use Command to copy into the Coursework folder whilst bypassing the name of ???
Thanks for any help.
If the .bat file script is run when the user is logged in, then it is simple.
COPY ".\Test.exe" "%USERPROFILE%\AppData\Local"
If the .bat file script is run while logged in as a different user (ie. "teacher"), then the username must be known AND the "teacher" account must have permission to write into the user's directories.

How can I make a batch script copy files from the user folder with support for different users?

I would like to use a short batch script to copy files from OneDrive to a different folder, the issue is the OneDrive folder is in the users folder under C:/.
What can I do to have the batch script go into the user folder of the user currently logged in followed by the OneDrive folder to copy a specific file?
Currently this is what I have:
xcopy "C:\jmills\OneDrive\TestFolder\Test_2018.accde" "C:\Test\Test_EXE\" /d
As you can see the user "jmills" is hard coded which makes the batch work with only this specific user.
It is hardcoded because you selected to hardcode it. Note that there is an environment variable called username which holds the username of the user currently logged in. Variables in batch file can be accessed by % or ! when delayed expansion is enabled. I find no reason for using delayed expansion here, so use just percent-signs:
xcopy "C:\%username%\OneDrive\TestFolder\Test_2018.accde" "C:\Test\Test_EXE\" /d

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.

Call .bat file from anywhere in the directory using python

I need to call a .bat file from anywhere in the directory without including the specific directory in the script. You'll just need to specify the name of .bat file you want to call and then run. Is this possible?
Add the .bat file's directory into your PATH.
This is an article for you.
http://www.computerhope.com/issues/ch000549.htm
do you mean calling a script without specifying the exact location from commandline?
there are two ways:
add it to your path (eg: set it in your PATH environment variable)
setup an alias/some sort of shortcut in your bashrc/whatever CLI you are using (since you are using windows, one example would be to setup a cmdlet in windows powershell or something)

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

Resources