Batch script to rename and move files - windows

I have a radio management system which is capable of running batch scripts after shows.
I'm looking for a batch script file that renames any file in the directory like so:
1.mp3 --> [Replay]1.mp3
And then move the file from folder a to folder b.
Any thoughts on how do i go about creating such script in a syntax level?

Here you go
ren *.mp3 [Replay]*.*

There are many ways to do what you request, this script does that by searching all mp3 files in the current folder and move them to folderb specifying a new name.
#ECHO off
FOR %%i IN (*.mp3) DO (
MOVE "%%i" "folderb\[Replay]%%i"
)

Related

Batch File Copy and Rename

Currently looking to copy and rename a file from a C:Drive source to a G:Drive destination by using a batch file. Currently have the following code:
robocopy C:\Users\abronk04\Desktop\Test G:\Users\abronk04\Desktop\Backup /e /purge
ren G:\Users\abronk04\Desktop\Backup accessbackup.jpg backup.jpg
The file will successfully copy, but there is no rename. Do I need to specify a file I am looking to rename? My batch file will copy an entire folder to another destination, unsure if that is the problem here...
I think you ren syntax is not correct.
Maybe try the following after copying the directory
pushd G:\Users\abronk04\Desktop\Backup
ren accessbackup.jpg backup.jpg
popd
This way you will temporarily change your working directory to the sink-path and then change it back

Moving files with .bat script on windows 10

Recently I wanted to make .bat script that would move .avi files from subfolders in specified directory to another directory.
e.g.
H:\MAINDIRECTORY\dir1\avi1.avi
H:\MAINDIRECTORY\dir2\avi2.avi
H:\MAINDIRECTORY\dir3\avi3.avi
....
To one directory called e.g.
H:\Movies
I've made script which looks something like this
#echo off
move H:\Pobrane\*\*.avi H:\Filmy
But when I'm tryin to execute it I got something like this:
the file name, directory name or volume lable syntax is incorrect
Please help me find a way out from this situation.
As move does not support wild cards you can try with for /r
#echo off
for /r "H:\Pobrane\" %%# in (*.avi) do (
move /y "%%~f#" "H:\Filmy"
)

run texconv windows batch file, recursively and output to the same folder as source?

im running texconv-r.bat in this directory:
I've included "/r" so that it runs recursively on folder "sub" too
for /r %%f in (*.jpg, *.png, *.bmp) do ( texconv -pow2 -f BC1_UNORM %%f )
however, the output places the contents of the sub directory, in the batch file directory:
rather, I would like it outputted to the same directory - the sub directory
I cant figure out what i need to change in the batch file to make this work? ive tried what's recommended in this post but i cant get it to work
Thanks in advance

Merge all files from the current folder and all subfolders in one file using .bat file

I'm looking for a batch file that merges the content of all files in the current directory and files from all subdirectories.
Also, that would be perfect if files were separated by several new lines in the big file and probably contain the filename with filepath above the each file content.
For example, there are two files in the current folder D:\ , where our batch file is located:
1.
d:\file1.txt contains:
some
text here
hahaha
2.
d:\folderabc\file2.mp3 contains:
doremi text
I run merge.bat file on d:\ and it creates a merge file result.txt (or whatever extension) with such content:
=========d:\file1.txt=========
some
text here
hahaha
=========d:\folderabc\file2.mp3=========
doremi
I appreciate if someone share his solution for this problem.
Thank you so much.
Test this with your folder. It assumes the files are text files.
edit: This has a fix - and you can remove the "d:\base\folder" to run it from the current directory.
#echo off
for /r "d:\base\folder" %%a in (*) do (
(
echo =========%%a=========
type "%%a"
echo(
echo(
echo(
)>>"%temp%\temp.file"
)
move "%temp%\temp.file" . >nul
echo done
pause

Creating Bat file to execute a command on all files in folder

How to create a bat file that will execute a single command on all files with a particular extension.
I look for something like this which is there is linux for windows batch files
command *.extension
or even a way to loop through the file with extension would do.
If your command changes the filename and uses the same extension then this solution has a bug, and some files are processed more than once. There are ways around that.
#echo off
for %%a in (*.ext) do (
echo "%%a"
)

Resources