Renaming multiple files in windows using command prompt? - batch-file

I have written a small batch file to move files from one folder to another folder.
copy E:\Source\Test.tif E:\Temp
Is there any way can I rename a file name after it has been moved to temp folder.Like
E:\Source:\TestInd1.tiff.
Please suggest.

You can do a move and a rename at the same time, yes:
move someFile S:\ome\Destination\newName

Related

How do I get previous directories and folders using PuTTY?

I created a directory root/, folder /temp and change it with emacs folder, and then add a file quote_dora. I want to add a text file to quote_dora.
I have figured it out already.
Runs emacs quote_dora
write text on quote_dora file
ctl-x and ctl-c to save and exist.

Check if file exists in 2 directories, delete files that aren't in both directories

So, I'm programming a game, but the compiler I use is written as a Windows batch file. I'm using Windows 10 as my operating system.
In my game files, I have one folder with images, and another folder with upscaled versions of those images that have the same file name and extension.
What I want to do is have the batch file go through all the images in the directory with the upscaled images, and check if a file with the same name and extension exists in the directory with the original images. If it doesn't exist in the original directory, it will delete it from the upscaled directory.
I got it working using an answer over here:
Batch Extract path and filename from a variable
All I had to do was extract the file name and extension, and then run all the files in one folder through the loop, checking if the file exists in the other folder.
Here is my code:
for %%i in (%folder1%\*.png) DO (
if not exist "%folder2%\%%~nxi" ECHO %%~nxi
)
If you actually want to delete the files, change ECHO to del /q, be warned you will lose files, so make sure you have backups.

Create batch file to copy mdb file to another folder and renaming it

I'm trying to create batch file to copy mdb file to another folder then renaming it and run a task scheduler everyday. so everytime the batch runs, the same mdb file will copy and rename. I don't care about the additional characters just copy and rename will do.
folder A (source folder)
test.mdb 06/21/2014
folder B (target folder)
test02.mdb 06/21/2014
test03.mdb 06/22/2014
thanks
copy "c:\folder a\test.mdb" "b:\folder b\test%random%.mdb"
The random number is 0 to 32,000. To do it by dates
Set NewDate=%date:/=%
copy "c:\folder a\test.mdb" "b:\folder b\test%newdate%.mdb"
This will copy and rename a file:
copy "folder A\test.mdb" "folder B\test02.mdb"

Batch File Copying

I am trying to copy a file from the C:\ drive to the steam directory using this
copy "C:\CSS.zip" "C:\%ProgramFiles86%\Steam\CSS.zip"
but it always makes a new folder and places the file in a new folder called %ProgramFiles86% but i want it to go in the actual Program Files (x86)
Thanks for the help
You aren't using the program files path correctly. Your code should be this:
copy C:\CSS.zip "%programfiles(x86)%\CSS.zip"

Make a batch file move files from the directory it is running from

How can I make a batch file move files from the directory it is running from? For example code:
**move {***CURRENT BATCH FILE DIRECTORY***}\Programs\myfile.txt**
What do I replace {***CURRENT BATCH FILE DIRECTORY***} with?
When you say "the directory it is running from", I assume you mean the folder that contains the currently executing batch file. If so, then you want %~dp0. The expansion will automatically append the trailing backslash.
move "%~dp0Programs\myfile.txt" "target folder"
Don't the "." (dot) work for you? I mean:
move .\Programs\myfile.txt
This works in Windows, if the current directory is where Programs is.
move "Programs\myfile.txt" "target folder"

Resources