English Amiga Board


Go Back   English Amiga Board > Support > support.Apps

 
 
Thread Tools
Old 06 March 2018, 15:02   #41
jPV
Registered User
 
jPV's Avatar
 
Join Date: Feb 2008
Location: RNO
Posts: 1,006
Quote:
Originally Posted by Foebane View Post
The problem I'm having now is that the script, when executed from DOpus, will invariably run TWICE, causing me to abort the second run. Why is it doing this?
Maybe because it has parenthesis in its name? They are special characters in AmigaDOS, so I would advice not to use them in file names no matter if it's the reason here or not. By using them you'll end up with trouble sooner or later anyway.. especially if handling such files from scripts.


Here's what Amiga manuals tell:

Colons (:) and slashes (/) are reserved and cannot be used in file or directory names. Semicolons (;), asterisks (*), parentheses (()), question marks (?), back apostrophes (`), number or pund signs (#), square brackets ([]), angle brackets (<>), tildes (~), vertical bars (|), dollar signs ($), double quotation marks ("), and percent signs (%) are not reserved; however, we recommend that you do not use these characters in your file or directory names because they have special meaning in AmigaDOS.
jPV is offline  
Old 06 March 2018, 15:07   #42
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,545
I'm not intended to make thing more complicated and I do not use DOpus,
but Diskmaster2 - on aminet, which seems down atm.

with zip archives, I also get wrong or not-set file attributes, zip does not preserves them.

what I do with diskmaster2, I was adding menu entries.
with diskmaster2 you allways have 2 listers, one source (%n) the other destination (%d).
so I select the archives (source) and use my "Archive --> Destination" entries.
so the archives get extracted in the destination location.

the config entries - 4 entries, each deals with one type of archive,
for SYS:S/Diskmaster2.prefs looks like this:
Code:
AddMenu Archives, Lha X >Dest, StdIO "CON:0/12/640/180/DM2";Extern Lha x %n %d;StdIO CLOSE
AddMenu Archives, Lzx X >Dest, StdIO "CON:0/12/640/180/DM2";Extern Lzx x %n %d;StdIO CLOSE
AddMenu Archives, UnZip >Dest, StdIO "CON:0/12/640/180/DM2";Extern unzip %n -d %d;StdIO CLOSE
AddMenu Archives, UnRar >Dest, StdIO "CON:0/12/640/180/DM2";Extern unrar x %n %d;StdIO CLOSE
you cannot use this config with DOpus, but there must be something equally simple with DirectoryOpus.

Last edited by emufan; 06 March 2018 at 15:14.
emufan is offline  
Old 06 March 2018, 15:10   #43
Foebane
Banned
 
Join Date: Sep 2011
Location: Cardiff, UK
Age: 51
Posts: 2,871
Quote:
Originally Posted by daxb View Post
You may doing something wrong. How do you start the script? Check DOpus flags that could cause it. SnoopDos can help.

If there isn't a good reason for it I would move the first line (Delete) at the end of the script.
It only happens sometimes. I ran it just now for a couple of WHDLoad games and it ran just fine, once. I set the S attribute because it's a script. I only really needed a way to abort the script if there was a problem, and it turns out Ctrl+D stops the script, according to the AmigaOS manual.

The Delete command is at the start in case there is a problem running the script, so by deleting any old script at the start then X.txt will be sure to be blank before the lists are added and then executed. I've been doing it like this for a long time, and there was never a problem with repeating executions, which have only happened very recently.

What are DOpus flags?

Quote:
Originally Posted by jPV View Post
Maybe because it has parenthesis in its name? They are special characters in AmigaDOS, so I would advice not to use them in file names no matter if it's the reason here or not. By using them you'll end up with trouble sooner or later anyway.. especially if handling such files from scripts.
Yes, I think you're right. The name change to include the brackets is recent, and now I come to think of it, coincides with the problem occurring. OK, I'll rename it without brackets and see how it goes.

EDIT: I'm surprised I didn't realise it would cause a conflict, when I already removed the brackets from .lha archives that would be used on Amiga already, only a few weeks before. D'oh!

Last edited by Foebane; 06 March 2018 at 15:50.
Foebane is offline  
Old 06 March 2018, 16:09   #44
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
Quote:
Originally Posted by Foebane View Post
What are DOpus flags?
If you are in the Functions Editor of DOpus (buttons, hotkeys, menu, datatypes) then you have {} button for arguments and below is a list of options.
daxb is offline  
Old 06 March 2018, 17:09   #45
jPV
Registered User
 
jPV's Avatar
 
Join Date: Feb 2008
Location: RNO
Posts: 1,006
Quote:
Originally Posted by Foebane View Post
The Delete command is at the start in case there is a problem running the script, so by deleting any old script at the start then X.txt will be sure to be blank before the lists are added and then executed.
You can optimize it a bit If you'd use ">" (single) redirection at the first list line (lha) then it'd start a new file always (no matter if there is an old file or not, it will be a fresh file always) and you don't need the delete line. Keep the ">>" (double) redirection just for the other lines (lzx and zip).
jPV is offline  
Old 06 March 2018, 18:19   #46
Foebane
Banned
 
Join Date: Sep 2011
Location: Cardiff, UK
Age: 51
Posts: 2,871
Quote:
Originally Posted by jPV View Post
You can optimize it a bit If you'd use ">" (single) redirection at the first list line (lha) then it'd start a new file always (no matter if there is an old file or not, it will be a fresh file always) and you don't need the delete line. Keep the ">>" (double) redirection just for the other lines (lzx and zip).
But the source folder for the archives will not always contain .lha archives, so again, the >> and Delete line are still required.
Foebane is offline  
Old 06 March 2018, 19:11   #47
jPV
Registered User
 
jPV's Avatar
 
Join Date: Feb 2008
Location: RNO
Posts: 1,006
Quote:
Originally Posted by Foebane View Post
But the source folder for the archives will not always contain .lha archives, so again, the >> and Delete line are still required.
No they aren't, because if there aren't any files found, the list command with > still creates a new (empty) file
jPV is offline  
Old 06 March 2018, 20:20   #48
Foebane
Banned
 
Join Date: Sep 2011
Location: Cardiff, UK
Age: 51
Posts: 2,871
Quote:
Originally Posted by jPV View Post
No they aren't, because if there aren't any files found, the list command with > still creates a new (empty) file
Hmm, I never considered that. Thank you, I will make the change for the next version of the script.
Foebane is offline  
Old 07 March 2018, 11:27   #49
Foebane
Banned
 
Join Date: Sep 2011
Location: Cardiff, UK
Age: 51
Posts: 2,871
The latest (last?) version of my script. More efficient than ever, thanks to people here for their advice!
Attached Thumbnails
Click image for larger version

Name:	001.png
Views:	181
Size:	29.1 KB
ID:	57163  
Foebane is offline  
Old 07 March 2018, 12:36   #50
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
Delete the script (.txt) after executing it is still an option if you don't want to have it sitting in RAM.
daxb is offline  
Old 07 March 2018, 15:22   #51
Foebane
Banned
 
Join Date: Sep 2011
Location: Cardiff, UK
Age: 51
Posts: 2,871
Quote:
Originally Posted by daxb View Post
Delete the script (.txt) after executing it is still an option if you don't want to have it sitting in RAM.
I'm guessing that a warm reset will erase it? I usually have to do those after every few games and demos anyway.
Foebane is offline  
Old 07 March 2018, 17:02   #52
jPV
Registered User
 
jPV's Avatar
 
Join Date: Feb 2008
Location: RNO
Posts: 1,006
Maybe changing those X:%N ones to %P%N would make it easier to update it later, if you want to change the location from where files are scanned.

I couldn't resist making an über cool (tm) more complicated and feature rich version of this script, sorry Maybe it would be fine learning material for anyone who would like to go deeper into wonderful world of Amiga shell scripting :P

It shows some information while progressing and also notifies if there were any errors in archives. You can also define different source and/or destination directories.

Here it is:
Code:
.KEY SOURCE,DEST
.DEF SOURCE X:
.DEF DEST RetroStuff:X/
; ^
; User can give source and destination direcotries, but defaults are also provided.
; Note that DEST must end with : or / always!

; Let's not stop on unarchiving errors, but handle them in our script.
FAILAT 20

; Print some information in bold.
ECHO "*E[1mUnpacking archives from <SOURCE> to <DEST>*E[22m"
ECHO "Scanning dir..."

; Let's use escape sequences to print information over the same line always. We'll handle any errors too.
LIST <SOURCE> PAT=#?.lha LFORMAT="ECHO *"**E[1F**E[K%P%N*"*NLhA -q x *"%P%N*" *"<DEST>%M/*"*NIF WARN*N ECHO *"**E[1F**E[KERROR IN: %P%N**E[1E*"*N SET ERR TRUE*NENDIF" > T:X.txt
LIST <SOURCE> PAT=#?.lzx LFORMAT="ECHO *"**E[1F**E[K%P%N*"*NLZX -q x *"%P%N*" *"<DEST>%M/*"*NIF WARN*N ECHO *"**E[1F**E[KERROR IN: %P%N**E[1E*"*N SET ERR TRUE*NENDIF" >> T:X.txt
LIST <SOURCE> PAT=#?.zip LFORMAT="ECHO *"**E[1F**E[K%P%N*"*NUnZip >NIL: -o *"%P%N*" -d *"<DEST>%M*"*NIF WARN*N ECHO *"**E[1F**E[KERROR IN: %P%N**E[1E*"*N SET ERR TRUE*NENDIF" >> T:X.txt
EXECUTE T:X.txt

ECHO "*E[1F*E[KDONE."

; If there was an error, let's wait that nothing closes the window too quickly if launched from DOpus etc.
IF $ERR EQ "TRUE"
 UNSET ERR
 WAIT 10
ENDIF
Attached Thumbnails
Click image for larger version

Name:	batchextract1.png
Views:	158
Size:	4.1 KB
ID:	57166   Click image for larger version

Name:	batchextract2.png
Views:	187
Size:	7.9 KB
ID:	57167  

Last edited by jPV; 08 March 2018 at 07:16.
jPV is offline  
Old 07 March 2018, 20:48   #53
Foebane
Banned
 
Join Date: Sep 2011
Location: Cardiff, UK
Age: 51
Posts: 2,871
I like your adaptation of my script, but I'm wondering what errors there could be when extracting them. I usually test the archives on the PC side with 7-zip, to make sure there are no problems there.
Foebane is offline  
Old 07 March 2018, 21:08   #54
jPV
Registered User
 
jPV's Avatar
 
Join Date: Feb 2008
Location: RNO
Posts: 1,006
I guess it's unlikely to see any then, but doesn't hurt to check for them either Anyway if someone wants to use this for other cases etc... will be good to see if something fails.
jPV is offline  
Old 08 March 2018, 06:37   #55
Foebane
Banned
 
Join Date: Sep 2011
Location: Cardiff, UK
Age: 51
Posts: 2,871
I loved the idea of the source and destination variables so much I implemented them into my own script, which now looks like this:

Code:
.KEY SRC,DST
.DEF SRC X:
.DEF DST RetroStuff:X/
LIST <SRC> PAT=#?.lha LFORMAT="LhA x *"%P%N*" *"<DST>%M/*"" >RAM:X.txt
LIST <SRC> PAT=#?.lzx LFORMAT="LZX x *"%P%N*" *"<DST>%M/*"" >>RAM:X.txt
LIST <SRC> PAT=#?.zip LFORMAT="UnZip *"%P%N*" -d *"<DST>%M*"" >>RAM:X.txt
EXECUTE >NIL: RAM:X.txt
It looks neater, I don't have to make changes in the three main lines anymore, and I can change the variables with ease.

Have you tried your script with zip files? I notice you have a trailing slash in the UnZip command, like the other two, but it won't work with it.
Foebane is offline  
Old 08 March 2018, 07:10   #56
jPV
Registered User
 
jPV's Avatar
 
Join Date: Feb 2008
Location: RNO
Posts: 1,006
Quote:
Originally Posted by Foebane View Post
It looks neater, I don't have to make changes in the three main lines anymore, and I can change the variables with ease.
Yeah, looks nice now

Quote:
Have you tried your script with zip files? I notice you have a trailing slash in the UnZip command, like the other two, but it won't work with it.
Yes I did and it worked. Maybe it depends of the UnZip version or something, these *nix ports are plenty and different always... I'll remove the slash from my example just in case though.

Last edited by jPV; 08 March 2018 at 07:16.
jPV is offline  
Old 08 March 2018, 09:24   #57
Foebane
Banned
 
Join Date: Sep 2011
Location: Cardiff, UK
Age: 51
Posts: 2,871
I discovered that the UnZip command cannot extract the .zip archives if the destination folder does not already exist, but it's no big issue. I tried to use MAKEDIR <DST> but no such luck.

Also, the "script running twice" bug is back. I thought Ctrl+D would abort it, but it didn't work. What is causing it to run twice?
Foebane is offline  
Old 08 March 2018, 16:02   #58
Foebane
Banned
 
Join Date: Sep 2011
Location: Cardiff, UK
Age: 51
Posts: 2,871
jPV, do you know what would happen if I use "RUN" on a script instead of "EXECUTE"?
Foebane is offline  
Old 08 March 2018, 18:58   #59
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
It will say something like can't execute file. If you set script bit on x.txt first, then should work. Why do you want to use RUN or do you mean the script you start manually?
daxb is offline  
Old 08 March 2018, 19:11   #60
Foebane
Banned
 
Join Date: Sep 2011
Location: Cardiff, UK
Age: 51
Posts: 2,871
Quote:
Originally Posted by daxb View Post
It will say something like can't execute file. If you set script bit on x.txt first, then should work. Why do you want to use RUN or do you mean the script you start manually?
I'm just wondering why, when the script is run as you describe above, it completes but then it runs once again automatically and asks if I want to overwrite the files I've just extracted! It should only run once, and sometimes it does, but sometimes it runs again immediately. Why?
Foebane is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to extract NDK39.lha Hiddenevil support.Apps 8 06 November 2017 11:14
Using Xdftool with LHA archives.. bugsymalone666 support.Other 6 25 June 2017 02:27
Self Extracting LHA Archives hipoonios support.Apps 7 16 January 2015 23:15
Dopus suddenly won't extract LhA Files manic23 support.Apps 3 30 March 2013 13:43
Any app to extract multiple archives??? keropi support.Apps 4 02 April 2007 13:21

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 19:35.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.20522 seconds with 14 queries