|
Post by George on Oct 10, 2021 10:00:47 GMT -5
Robert: As I've said before, ditch File Explorer and get something better, even if you have to pay for it. I still highly recommend DOpus (Directory Opus) ~~ $AUS 50.00. I use it to Sync my desktop and offline storage. Open the two locations in a two pane view, enter Ctrl-Y, verify the Sync option settings and click to start it.
Throw in all the other 'goodies' it has and you'll never use Explorer again.
It's a shame to re-invent the wheel.
|
|
|
Post by Stefan on Oct 10, 2021 17:04:23 GMT -5
Robert, Years ago I used XCOPY in a .BAT file, but subsequently wrapped it in some REXX. This would be easy to do in thinBASIC too.
To get a list of files that exist in both paths, use
XCOPY "path-1\*.*" "path-2\" /s /C /E /Y /H /L /U >WhatsInBoth.txt To get a list of files that are unique (or newer) in one or other path, use XCOPY "path-1\*.*" "path-2\" /s /C /E /Y /H /L /EXCLUDE:WhatsInBoth.txt >WhatsInOnly.txt
In fact, if you're just looking to copy new files to the phone, do both commands but omit the /L on the second one. XCOPY will then just copy the newer files. There is also a /D:m-d-y option that offers more direct date control. (See HELP XCOPY )
The REXX wrapper just parses the command parameters Creates two temp files called WhatsInBoth.txt and WhatsInOnly.txt and writes their headers (so moron-me can tell them apart). Displays the appropriate output file using NOTEPAD depending on the condition (AND / NOT) Deletes the files once NOTEPAD finishes.
That way I can say WHATISIN path-1 AND path-2 or WHATSIN path-1 NOT path-2
The core logic is:
Parse command parameters to extract & validate p1, p2 and cond (AND or NOT) inboth = ENV_DECODE("%TEMP%\WhatsInBoth.txt") /* Obtain two temp... */ inonly = ENV_DECODE("%TEMP%\WhatsInOnly.txt") /* ...file names */ /*-----------------------------------------------------------------------*/ /* Using XCOPY: /L /U lists files in both directories */ /*-----------------------------------------------------------------------*/ sep = COPIES("=",max(p1~length,p2~length)+4) IF Cond = "AND" THEN DO /* Cond 'AND' header */ answer = inboth '@ECHO ====================='sep' >"'inboth'"' '@ECHO Files found in both "'p1'" >>"'inboth'"' '@ECHO and "'p2'" >>"'inboth'"' '@ECHO ====================='sep' >>"'inboth'"' SAY "Collecting information for files in both folders" END 'XCOPY "'p1'*.*" "'p2'" /s /C /E /Y /H /L /U >>"'inboth'"' IF cond = "NOT" THEN DO /* Cond 'NOT' headers */ answer = inonly SAY "Collecting information for files only in '"p1"'" '@ECHO ====================='sep' >"'inonly'"' '@ECHO Files found only in "'p1'" >>"'inonly'"' '@ECHO ====================='sep' >>"'inonly'"' 'XCOPY "'p1'*.*" "'p2'" /s /C /E /Y /H /L /EXCLUDE:'inboth' >>"'inonly'"' '@ECHO. >>"'inonly'"' SAY "Collecting information for files only in '"p2"'" '@ECHO ====================='sep' >>"'inonly'"' '@ECHO Files found only in "'p2'" >>"'inonly'"' '@ECHO ====================='sep' >>"'inonly'"' 'XCOPY "'p2'*.*" "'p1'" /s /C /E /Y /H /L /U >"'inboth'"' 'XCOPY "'p2'*.*" "'p1'" /s /C /E /Y /H /L /EXCLUDE:'inboth' >>"'inonly'"' END 'NOTEPAD "'answer'"' /* Display the results */ 'ERASE "'inboth'"' /* Tidy up temp files */ IF cond = "NOT" THEN 'ERASE "'inonly'"'
|
|
|
Post by George on Oct 11, 2021 9:12:06 GMT -5
If you work with the MS stuff it can be very powerful, if cryptic.
Recently I wanted to get the Julian date in a BAT file, and found some sample code that does it, but I've studied and studied it and can't figure a lot of it out. I can see the basic logic, but there's some BAT syntax in there I just don't understand.
Just FYI.
echo off setlocal EnableDelayedExpansion set /A i=0, sum=0 for %%a in (31 28 31 30 31 30 31 31 30 31 30 31) do ( set /A i+=1 set /A accum[!i!]=sum, sum+=%%a ) if "%1"=="" ( for /F "tokens=2 delims==" %%D in ('wmic OS GET LocalDateTime /VALUE ^| find "="') do ( set CurrDate=%%D ) ) else ( set CurrDate=%1 ) set /A month=1%CurrDate:~4,2%-100, day=1%CurrDate:~6,2%-100 set /A yearMOD4=%CurrDate:~0,4% %% 4 set /A yearMOD100=%CurrDate:~0,4% %% 100, yearMOD400=%CurrDate:~0,4% %% 400 set /A dayOfYear=!accum[%month%]!+day if %month% gtr 2 ( if %yearMOD4% equ 0 set /A dayOfYear+=1 if %yearMOD400% neq 0 if %yearMOD100% equ 0 set /A dayOfYear-=1 ) endlocal & set dayOfYear=%dayOfYear% echo ON
|
|