blog:x68_directory_backup

X68000 - Backing up folders

You can copy content out of an emulated X68000 hard drive using Disk Explorer, but it's buggy and even a Linux filesystem can choke on certain S-JIS characters from the Sharp.

It's much easier to archive up the folders you want to backup or transfer, and then keep them zipped until they need restoring, or are copied to their destination.

Normally, in MS-DOS you would do something like:

for /D %%D IN (A:\Games\*.) DO zip.exe $D.ZIP $D

… which would expand to include all of the directories under A:\Games. However, the command prompt in Human68K does not support the /D directory switch for the for statement, meaning it only matches files.

Rather than doing this by hand for all the hundreds of games folders on the emulated hard drive, I came up with an automated solution using a few small extra commands.

The following small utilities need to be dropped in to your A:\Bin folder on the X68000:

#!bash
#######################################
#
# A quick script to backup a directory
# of folders to individual archives on
# Human68k... since the for %% in ()
# syntax does not work for directories
#
# Needs:
#
# - zip.x
# - bash.x
# - ls.x
# - tr.x
#
#######################################

OUTPUT="E:\backup\a\games"

echo "Generating list..."

ls.x -1 | tr.x -d '\015' > files.txt 

>cmd.bat

echo "Starting to write batch file..."

while read D
do

	test -d "$D"
	if [ "$?"=="0" ]
	then

		d=`echo $D`
      
		echo -n "zip.x -b A:\\tmp -0 $OUTPUT\\$d.zip $d\\*.*"  >> cmd.bat
		echo -e "\r" >> cmd.bat     
	fi

done < files.txt

echo "Now run cmd.bat"

You run the script with bash: bash.x pack.sh, and it will generate a batch file for you with all of the commands to archive your directories. Simply run the batch file and it will zip them up, dropping them in to the specified output folder.

The script will of course work on both emulated and real hardware and preserves any S-JIS filenames present.

  • blog/x68_directory_backup.txt
  • Last modified: 2021/04/06 15:41
  • by john