#program CopyDir 3000 REM SORTED - copy the contents of a directory to 3010 REM another, placing files in alphabetical order 3020 REM PROC CopyDir() - Last updated 6th June 2021 3030 REM VERSION 1.7 Copyright 2021 Simon N Goodwin 3040 3050 DEFPROC CopyDir(s$,%q) 3055 LOCAL i,f$,p,b,c 3060 IF LEN s$=0 THEN PRINT "CopyDir(""newDirectoryName"",q)": STOP 3070 IF s$( LEN s$)<>"/" AND s$( LEN s$)<>"\" THEN LET s$=s$+"/" 3075 PRINT "Preparing to copy to ";s$'' 3080 MKDIR s$(1 TO LEN s$-1) 3090 CLOSE # 2 3100 LET f$="m:temp.txt": REM Temporary file on another drive! 3110 LET c=4: REM File channel to use 3120 CLOSE # c 3130 REM Divert directory listing to f$ 3140 OPEN # 2,"O>"+f$ 3150 .ls -AB -w 255 --gdf --lfn=on 3160 CLOSE # 2 : REM Restore display output 3170 OPEN # c,"I>"+f$ 3180 DIM #c TO b: REM Listing length in bytes 3190 REPEAT 3200 RETURN #c TO p 3210 WHILE p2 THEN COPY a$ TO s$+a$: LET i=i+1 3240 REPEAT UNTIL 0 3250 CLOSE # c 3260 ERASE f$ 3270 PRINT "Copied ";i;" file"+("s" AND i<>1) 3280 ENDPROC 3290 3300 DEFPROC QUERY(f$) 3310 PRINT f$;" "; INVERSE 1;" Y/N/A/Q "; 3320 LET %q=3 3330 REPEAT 3340 PAUSE 1: PAUSE 0 3350 LET t$= INKEY$ 3360 IF t$>="a" THEN LET t$= CHR$ ( CODE t$-32) 3370 IF t$="A" THEN LET %q=4 3390 IF t$="N" THEN LET %q=2 3400 IF t$="Y" THEN LET %q=1 3410 IF t$="Q" THEN STOP 3420 REPEAT UNTIL %q<>3 3430 PRINT t$ 3450 ENDPROC 3500 3900 REM parameter 2 = 0 to empty and delete directory, 1 to ask 3910 REM if each individual file should be deleted. 4000 DEFPROC EraseDir(s$,%q) 4010 LOCAL a$,b,c,d,f$,p 4020 IF LEN s$=0 THEN PRINT "EraseDir ""DirectoryName"",q": STOP 4040 IF s$( LEN s$)<>"/" AND s$( LEN s$)<>"\" THEN LET s$=s$+"/" 4060 PRINT "Preparing to erase ";s$ 4070 CLOSE # 2 4080 LET f$="m:temp.txt": REM temporary file 4090 LET c=11: REM channel to use 4100 CLOSE # c 4110 CD s$ 4120 OPEN # 2,"O>"+f$ 4130 .ls -A -w 255 --gdf --lfn=on 4140 CLOSE # 2 4150 OPEN # c,"I>"+f$ 4160 DIM #c TO b 4170 REPEAT 4180 RETURN #c TO p 4190 WHILE p2 THEN ERASE a$: PRINT a$;" erased": LET d=d+1 4220 REPEAT UNTIL 0 4230 CLOSE # c 4240 PRINT INVERSE 1;" ";d;" file";"s" AND d<>1;" erased " 4245 ERASE f$ 4250 CD ".." 4260 IF %q THEN ENDPROC 4270 RMDIR s$( TO LEN s$-1) 4280 PRINT " Directory ";s$;" removed " 4290 ENDPROC 4300 9999 CLEAR : SAVE "CopyDir.bas"