Rename Multiple Files without downloading additional software
You can create a batch file to accomplish the task. You copy the code below to notepad and save it with the name that you want but with a *.bat extension.
Change the this part according to your needs and click the batch file set Source= set Destiny=
@echo off
:: here you infrorm the script where the source and destiny are:
set Source=D:\FileHistory\myuser\LAPTOP-78RBSL7E\Data\C\Users\myuser\Desktop\Education\High School\G12\Politics
set Destiny=C:\Users\myuser\Desktop\Education\High School\G12\Politics
:: This gets the full path of the source:
for /f "delims=" %%a in ("%Source%") do set Source=%%~dpnxa
:: This creates the destiny in case it doesn't exist already:
IF not exist "%Destiny%\" md "%Destiny%"
:: This sends the full path of each source file to the rename funcion
For /f "Delims=" %%a in ('dir /b /s /a-d "%Source%\*"') do call :Rename "%%~a"
exit
:: Here the renaming is done:
:Rename
set "PartName=%~1"
call set "PartName=%%PartName:%Source%=%%"
for /f "tokens=1,3 delims=()" %%a in ("%PartName%") do set "PartName=%%~a"
if "%PartName:~-1%"==" " set "PartName=%PartName:~0,-1%"
IF /i not exist "%Destiny%%PartName%%~x1" echo F |xcopy /q /k "%~1" "%Destiny%%PartName%%~x1"
goto :EOF
Not the most efficient PowerShell code, but the most straight-forward off the top of my head.
$BackupFileRoot = 'D:\FileHistory\myuser\LAPTOP-78RBSL7E\Data\C\Users\myuser'
$RestoreToRoot = 'C:\Users\myuser'
### Recreate Directory Structure
(Get-ChildItem $BackupFileRoot -Directory -Recurse).FullName | ForEach{
$RestorePath = $_.Replace( $BackupFileRoot , $RestoreToRoot )
If ( !( Test-Path $RestorePath ) )
{
md $RestorePath -Force | out-null
}
}
### Restore Files
$RegExFind = ' \([\w ]+UTC\)'
Get-ChildItem $BackupFileRoot -File -Recurse -Force | ForEach{
$RestorePath = $_.FullName.Replace( $BackupFileRoot , $RestoreToRoot ) -replace ( $RegExFind , '' )
If ( !( Test-Path -LiteralPath $RestorePath ) )
{
Copy-Item -LiteralPath $_.FullName $RestorePath
}
}