Answer the question
In order to leave comments, you need to log in
How to bulk rename files from two different folders?
Hello.
Please tell me a solution for mass renaming files.
Folder #1 contains a music database that looks like this:
MKDL10123_Pupko, Ivan_-_Track 1.wav
MKDL10144_Prosto, Kostya_-_Track 2.wav
MKDL10147_Good, Man_-_Track 352.wav
Folder #2 stores program extension files that have the following look:
MKDL10123.wav_dig
MKDL10123.wav_env
MKDL10144.wav_dig
MKDL10144.wav_env
MKDL10147.wav_dig
MKDL10147.wav_env
Task: to make all files from data folder #2 look like this:
MKDL10123_Pupko, Ivan_-_Track
1_wav_Pok3 1.wav_env
MKDL10144_Prosto, Kostya_-_Track 2.wav_dig
MKDL10144_Prosto, Kostya_-_Track 2.wav_env
MKDL10147_Good, Man_-_Track 352.wav_dig
MKDL10147_Good, Man_-_Track 352.wav_env
The music database has more than 5 thousand files, I don’t want to work with handles.
Surely, in Total Commander or Windows tools, you can somehow massively rename files. I will be glad if someone will prompt/help to carry out the task. Thanks in advance!
Answer the question
In order to leave comments, you need to log in
For such tasks, there is Powershell.
I think this script will help you
$dir1 = "C:\1" #folder where you need to take names for files
$dir2 = "C:\2" #folder where files will be renamed
$folder1 = Get-ChildItem -Path "$dir1" | Select-Object -ExpandProperty Name
$folder2 = Get-ChildItem -Path "$dir2" | Select-Object -ExpandProperty Name
$folder1 = $folder1 -replace ".wav",""
foreach ($fold in $folder2)
{
$tmp = $fold.split(".")[0]
$tmp2 = $folder1 | Where-Object {$_ -like "*$tmp*"}
$tmp3 = $fold.split(".")[-1]
$newname = "$tmp2.$tmp3"
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question