|
* TinkerDifferent *
Retro Computing Community |
| Home | Forums | What's New | Search | Settings |
| Script for copying files to BlueSCSI SD |
|
V.Yakob Tinkerer Syktyvkar -------- Joined: Sep 6, 2023 Posts: 129 Likes: 46 |
Sep 2, 2025 - #1
We all know about the problem with file fragments when copying using Finder to the BlueSCSI SD card.
A few years ago, when I got my first BlueSCSI, this problem made me think about how to copy files, and at the same time not open the terminal window every time for this. Usually I perform all my automation on Mac using AppleScript, this case was no exception. AppleScript fits perfectly into Shortcuts.app. [Script: --Определяем глобальные переменные global PathToSD, ConfigPaths -- Путь до SD карты set PathToSD to "/Volumes/BLUESCSISD/" -- Структура каталогов и файлов set ConfigPaths to {folders:{"CD3", "CD3 (Disabled)", "HDs", "HDs (Disabled)", "DEVs", "shared"}, file:{"bluescsi.ini", "NE6.hda"}} -- Содержимое файла bluescsi.ini set BSConfig to "[SCSI] #Same effect as DIPSW2, enables verbose log messages #Debug = 1 # On #Wi-Fi settings WiFiSSID = \"Old-Mac-Net\" #Optionally look for image files in subdirectory #Multiple directories can be specified Dir1...Dir9 Dir1 = \"/HDs\" Dir2 = \"/DEVs\" [SCSI3] #Reinsert any ejected CD-ROM image on Inquiry command, 1 to enable, default off. ReinsertCDOnInquiry = 1" -- Получаем выбранные файлы в Finder и передаём их в обработчик копирования tell application "Finder" to set selectedFiles to selection -- Вызов обработчиков SyncData(PathToSD) CreateBSFolders(folders of ConfigPaths) CreateBSConfig(PathToSD & (item 1 of file of ConfigPaths), BSConfig) CreateWiFiDevice(PathToSD & (item 5 of folders of ConfigPaths) & "/" & (item 2 of file of ConfigPaths)) copyFilesToBlueSCSI(selectedFiles) -- === Обработчики === -- Обработчик для проверки и создания каталогов on CreateBSFolders(folderNames) repeat with folderName in folderNames tell application "System Events" -- Проверяем, существует ли папка if not (exists folder (PathToSD & folderName)) then -- Создаём новый каталог make new folder at folder PathToSD with properties {name:folderName} end if end tell end repeat end CreateBSFolders -- Обработчик создания конфигурации bluescsi.ini on CreateBSConfig(filePath, BSConfig) tell application "System Events" if not (exists file filePath) then -- Открываем файл для записи, создаём его, если не существует set ConfigFile to open for access (POSIX file filePath as text) with write permission -- Записываем содержимое в файл write BSConfig to ConfigFile starting at eof -- Закрываем файл после записи close access ConfigFile end if end tell end CreateBSConfig -- Обработчик создания устройства Wi-Fi on CreateWiFiDevice(filePath) tell application "System Events" if not (exists file filePath) then -- Создаем пустой файл set newFile to open for access POSIX file filePath with write permission close access newFile end if end tell end CreateWiFiDevice -- Обработчик копирования файлов on copyFilesToBlueSCSI(selectedFiles) set hdaFolder to PathToSD & (item 3 of folders of ConfigPaths) & "/" -- "HDs" set imagesFolder to PathToSD & (item 1 of folders of ConfigPaths) & "/" -- "CD3" set sharedFolder to PathToSD & (item 6 of folders of ConfigPaths) & "/" -- "shared" repeat with aFile in selectedFiles set sourcePath to POSIX path of (aFile as alias) set fileName to name of aFile -- Получаем расширение файла set AppleScript's text item delimiters to "." set fileExtension to last text item of fileName set AppleScript's text item delimiters to "" -- Определяем целевой каталог if fileExtension is "hda" then set destinationPath to hdaFolder & fileName else if {"iso", "toast", "cdr"} contains fileExtension then set destinationPath to imagesFolder & fileName else set destinationPath to sharedFolder & fileName end if -- Копируем файл do shell script "cp -X" & space & quoted form of sourcePath & space & quoted form of destinationPath SyncData(PathToSD) end repeat end copyFilesToBlueSCSI on SyncData(VolPath) -- Убеждаемся в завершении операции do shell script "sync -f" & space & quoted form of VolPath end SyncData] Select the necessary files and call the command through the context menu. Before copying, if you need to create bluescsi.ini and directories, then copy. It seems to me that since I started using this script, I no longer encountered the problem of fragmented files. I hope it will be useful to someone. :)
Liked by modsk0 |
| Page 1 of 1 |
| Home | Forums | What's New | Search | Bookmarks | RSS | Original | Settings |
| XenForo Retro Proxy by TinkerDifferent.com |