GET all files in a directory (using Wildcard * or *.*) with HDFmonkey out of a .HDF-Image

Struggling with Fuse or trying to find an emulator with a specific feature. Ask your questions here.
Post Reply
User avatar
Luzie
Manic Miner
Posts: 917
Joined: Fri May 01, 2020 2:07 pm

GET all files in a directory (using Wildcard * or *.*) with HDFmonkey out of a .HDF-Image

Post by Luzie »

Does anybody know a way to get all files in a directory (using Wildcard * or *.*) with HDFmonkey.exe out of a .HDF-Image? I can only get single files, but not a whole directory.
User avatar
PeterJ
Site Admin
Posts: 6966
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: GET all files in a directory (using Wildcard * or *.*) with HDFmonkey out of a .HDF-Image

Post by PeterJ »

@Luzie,

Can I suggest HDFMGooey? It's not perfect, but is good for copying masses of files and directories.

Or, did you answer the question here?

https://forum.tlienhard.com/phpBB3/view ... 406#p50195
User avatar
Luzie
Manic Miner
Posts: 917
Joined: Fri May 01, 2020 2:07 pm

Re: GET all files in a directory (using Wildcard * or *.*) with HDFmonkey out of a .HDF-Image

Post by Luzie »

PeterJ wrote: Tue Sep 20, 2022 7:26 pm @Luzie,

Can I suggest HDFMGooey? It's not perfect, but is good for copying masses of files and directories.
Dear @PeterJ. as HDFMGooey is internally using HDFmonkey.exe it too can only put a whole directory into the image, but cannot get a whole directory including files in that directory back.

Also on:
PeterJ wrote: Tue Sep 20, 2022 7:26 pm Or, did you answer the question here?

https://forum.tlienhard.com/phpBB3/view ... 406#p50195
...sadly the same: Only put a whole directory and not get of a whole directory.

Maybe we can write a script to process the file-list we get with "HDFmonkey ls HDF-File.HDF directoryname" which lists all filenames in a directory
User avatar
PeterJ
Site Admin
Posts: 6966
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: GET all files in a directory (using Wildcard * or *.*) with HDFmonkey out of a .HDF-Image

Post by PeterJ »

@Luzie,

I'm sure I read that HDFmonkey can't handle empty directories which sounds linked to this. Your solution sounds like a great one.

PS, I was aware that HDFMGooey used HDFmonkey, but hadn't tried the bulk copy off the image. Apologies.

As mentioned previously, I wish it was possible just to mount an HDF image as a drive in Windows and just move files like you can with an SD card.
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: GET all files in a directory (using Wildcard * or *.*) with HDFmonkey out of a .HDF-Image

Post by Alessandro »

I think you can only extract one single file at a time from HDF disk image files. At least that's what happens with the HDFM-Gooey graphical user interface. The help given by typing "hdfmonkey help get" also mentions a single file and no wildcards so it seems to be like that.
User avatar
Luzie
Manic Miner
Posts: 917
Joined: Fri May 01, 2020 2:07 pm

Re: GET all files in a directory (using Wildcard * or *.*) with HDFmonkey out of a .HDF-Image

Post by Luzie »

Alessandro wrote: Wed Sep 21, 2022 3:01 pm The help given by typing "hdfmonkey help get" also mentions a single file and no wildcards so it seems to be like that.
@Alessandro Thank you. I didn´t recognize that:
hdfmonkey.exe help get

get: Copy a file from the disk image to a local file
usage: hdfmonkey get <imagefile> <sourcefile> [destfile]
Will write the file to standard output if no destination file is specified.
In the meantime I found a solution using a Windows Batchfile. This can get all files from a specified directory (but not Sub-Directories of this directory).

It utilize the output of the HDFmonkey "ls" command which is e.g.:

Code: Select all

hdfmonkey.exe ls hdfmaker.hdf dot
685     checkerb
7260    ESPBAUD
[DIR]   extra
8192    http
51200   odin
8192    ping
8192    wc
This Windows-Batchfile gets all files from the "dot"-Directory in the HDF-File:

Code: Select all

	REM Extract_all_Files_from_one_Directory_of_a_HDF-Image-File.BAT
	REM Does not extract files in SubDirectories of the selected Directory
	REM v0.01 by Luzie
	
SET hdfmonkeyexe=hdfmonkey.exe

SET hdffilename=HDFMaker.HDF

SET Directory-Name=dot

%hdfmonkeyexe% ls %hdffilename% %Directory-Name% > DIR-TEMP1.TXT

	REM Delete all Lines containing [DIR]
type DIR-TEMP1.TXT | find /v "[DIR]" > DIR-TEMP2.TXT

for /f "tokens=2" %%i in (DIR-TEMP2.TXT) do echo %%i >> DIR-TEMP3.TXT

MD %Directory-Name%

for /f "tokens=2" %%i in (DIR-TEMP3.TXT) do HDFmonkey.exe get %hdffilename% %Directory-Name%\%%i %Directory-Name%\%%i

	REM get
for /f %%i in (DIR-TEMP3.TXT) do HDFmonkey.exe get %hdffilename% %Directory-Name%\%%i %Directory-Name%\%%i

DEL DIR-TEMP1.TXT
DEL DIR-TEMP2.TXT
DEL DIR-TEMP3.TXT
This maybe useful if you create multiple files in an Emulator with attached .HDF-File and want to get this files from out of the Emulator/.HDF-File.
User avatar
Luzie
Manic Miner
Posts: 917
Joined: Fri May 01, 2020 2:07 pm

Re: GET all files in a directory (using Wildcard * or *.*) with HDFmonkey out of a .HDF-Image

Post by Luzie »

Life could be easier if we use the right tools :lol: ...

While doing some research to extract a complete Directory/Subdirectory-Tree I discovered on: https://superuser.com/questions/321829/ ... mmand-line that 7-Zip not only can unpack a whole .HDF or .RAW-HDF-Image-FIle, but even a SubDir or selected files from it.

So the easy solution for extracting a complete Directory-Tree to an Output-Directory called "Outputdir" could be:

Code: Select all

7z.exe x NameofHDFFile -oOutputdir DirectoryNameInHDFFile
User avatar
Luzie
Manic Miner
Posts: 917
Joined: Fri May 01, 2020 2:07 pm

Re: GET all files in a directory (using Wildcard * or *.*) with HDFmonkey out of a .HDF-Image

Post by Luzie »

PeterJ wrote: Tue Sep 20, 2022 8:04 pm As mentioned previously, I wish it was possible just to mount an HDF image as a drive in Windows and just move files like you can with an SD card.
It maybe easier to directly drag and drop files into a .HDF-File with this Windows Batchfile:
You can drop (one) file on this example-Batchfile and it´s written to HDF-Image-Files even if they are opened/running in an Emulator:

Code: Select all

	REM Drag_and_Drop_to_Directory_TESTS_in_HDF-Files_HDFMAKER.HDF_and_HDFMAKER.RAW.bat
		REM v0.11, Luzie

SET hdfmonkeyexe=hdfmonkey.exe

SET Destination-Directory=\TESTS

%hdfmonkeyexe% mkdir HDFMAKER.HDF %Destination-Directory%
%hdfmonkeyexe% mkdir HDFMAKER.RAW %Destination-Directory%

	REM Drag and drop files into batch file
	REM https://www.dostips.com/forum/viewtopic.php?t=7783

@echo off
setlocal enableExtensions disableDelayedExpansion

	REM if using more than 9 arguments you may use the "shift" command
	REM echo Command line: %0 %*
	REM echo Command line argument 1: "%~1"

	REM https://ss64.com/nt/syntax-args.html
	REM The modifiers above can be combined: ~nx2 Expand %2 to a file name and extension only.
	
echo Command line argument 1: "%~nx1"

%hdfmonkeyexe% put HDFMAKER.HDF "%~1" "%Destination-Directory%\%~nx1"
%hdfmonkeyexe% put HDFMAKER.RAW "%~1" "%Destination-Directory%\%~nx1"

endlocal
goto :eof
The other way aound (getting files/directories from a HDF-File) can also "automated" by a Batchfile which starts the Emulator and after quit of Emulator automatically gets the files/directories.
Post Reply