Script for Symlink creation NEW VERSION
2 posters
Page 1 of 1
Script for Symlink creation NEW VERSION
Hey All,
I am unable to donate to RetroBat right now due to tight funds. However, I have created a script that some might find beneficial.
The process outlined on the wiki for creating symlinks is fine but powershell can do all the symlinks at once
So I have created two scripts. One for use for local drives. Like a secondary drive or external hard drive. The next is a script if you are running your roms on a NAS.
Hopefully it is helpful to someone!
EDIT: Updating the network version of the script. This verifies there is no files present in the directory where symlinks are being created. Future versions will have local and network functionality merged together. I have used this script for my ROMs directory and saves directory.
I am unable to donate to RetroBat right now due to tight funds. However, I have created a script that some might find beneficial.
The process outlined on the wiki for creating symlinks is fine but powershell can do all the symlinks at once
So I have created two scripts. One for use for local drives. Like a secondary drive or external hard drive. The next is a script if you are running your roms on a NAS.
Hopefully it is helpful to someone!
EDIT: Updating the network version of the script. This verifies there is no files present in the directory where symlinks are being created. Future versions will have local and network functionality merged together. I have used this script for my ROMs directory and saves directory.
- Code:
#This is for local use like when you have a external hard drive with all your ROMs
#Directory where your Rom files live
$SourceRomDir = "s:\retrobat\roms"
#Directory Where Retrobat is installed and ROMs folder is
$LocalRetroBatDir = "C:\Retrobat\roms"
#Gets names of folders in your source directory
$directories = Get-ChildItem $SourceRomDir
#Loops through each folder and creates Symlink
foreach($dir in $directories.name)
{
New-Item -ItemType SymbolicLink -path "$LocalRetroBatDir\$dir" -target "$SourceRomDir\$dir"
}
- Code:
#This is for network use like when you have your ROMs on a NAS
#Static Variables
#verification nas:\ is not in use
$TestPath = test-path nas:\
#Directory where your Rom files live
$SourceRomDir = "nas:\retrobat\saves"
#Drirectory Where Retrobat is installed and ROMs folder is
$LocalRetroBatDir = "C:\Retrobat\saves"
#friendly name of sahred drived map
$PSDriveName = "nas"
#UNC Path to shared folder where Root folder RetroBat is (I have the entire folder tree mirrored to my nas by installing retrobat there you can use something like robocopy to do this if you dont have a windows backend)
$SharePath = "\\192.168.1.1\NAS"
#Gets items in specified $LocalRetroBatDir if null it means the directory is empty
$TestEmptyDirectory = Get-ChildItem $LocalRetroBatDir
#Gets names of folders in your source directory
$directories = Get-ChildItem $SourceRomDir
#Assists in stopping the user before deletion happens
$WarningPreference = "Inquire"
#Test if shared drive is already mapped
if($TestPath -eq $true)
{
#Removes drive with conflicting name
Remove-PSDrive -Name $PSDriveName -Force
#Create temporary drive with your retro bat files
New-PSDrive -Name $PSDriveName -PSProvider "FileSystem" -Root $SharePath
}
#Test if shared drive is not mapped
elseif($TestPath -eq $false)
{
#Create temporary drive with your retro bat files
New-PSDrive -Name $PSDriveName -PSProvider "FileSystem" -Root $SharePath
}
#Test if the directory where symlinks are being created is clean
if($TestEmptyDirectory -eq $null)
{
#Loops through each folder and creates Symlink
foreach($dir in $directories.name)
{
#Creating symlinks
New-Item -ItemType SymbolicLink -path "$LocalRetroBatDir\$dir" -target "$SourceRomDir\$dir"
}
}
else
{
Write-Warning "****WARNING****`n BY ALLOWING THIS SCRIPT TO RUN FUTHER YOU ARE MAKING THE CHOICE TO DELETE ITEMS IN THE PATH YOU SPECFIED INCLUDING ALL NESTED ITEMS `n IF YOU ARE UNSURE OR WANT TO STOP DO SO NOW!!!! `n ****WARNING****"
#Removes items in the directory where symlinks are going
remove-item $LocalRetroBatDir\* -Recurse
#Loops through each folder and creates Symlink
foreach($dir in $directories.name)
{
#Creating symlinks
New-Item -ItemType SymbolicLink -path "$LocalRetroBatDir\$dir" -target "$SourceRomDir\$dir"
}
}
Last edited by dragoonluver on 15/08/24, 03:21 pm; edited 1 time in total
dragoonluver- Messages : 2
Date d'inscription : 2024-08-07
tartifless- Admin
- Messages : 1674
Date d'inscription : 2021-04-27
Re: Script for Symlink creation NEW VERSION
That is a good point. However, I try to keep within the vendors specs:
https://wiki.retrobat.org/tutorials/symbolic-links
They show each emulator getting its own Symlink.
Classic me making things harder than it needs to be XD
https://wiki.retrobat.org/tutorials/symbolic-links
They show each emulator getting its own Symlink.
Classic me making things harder than it needs to be XD
dragoonluver- Messages : 2
Date d'inscription : 2024-08-07
Similar topics
» [TUTO VIDEO] Creation d'une collection.
» I found a bug in the creation of dynamic collections
» Création de catégories pour regrouper les différents Systèmes
» [RESOLVED] Thinking ahead about final burn neo and retrobat updates (Since the rom version is specific to the emulator version, is there a way for me to stop updates to final burn within retrobat)
» Probleme script Retrobat V6
» I found a bug in the creation of dynamic collections
» Création de catégories pour regrouper les différents Systèmes
» [RESOLVED] Thinking ahead about final burn neo and retrobat updates (Since the rom version is specific to the emulator version, is there a way for me to stop updates to final burn within retrobat)
» Probleme script Retrobat V6
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum