android - Batch file parsing text file from UNIX -
i'm attempting write batch file backs files android phone computer. part of process having phone generate file list text file using android debug bridge, , checking against text file containing file list of 7zip archive i'm backing phone to.
the problem file list generated using android debug bridge doesn't seem parse correctly.
"c:\%userprofile%\adb\adb.exe" shell ls /sdcard/twrp/backups/0149bcaa1301701a > androidlist2.txt "c:\program files\7-zip\7z.exe" l twrpbackups.t7z > archivelist.txt type archivelist.txt | findstr twrp\backups\0149bcaa1301701a\ > results.txt del archivelist.txt setlocal enabledelayedexpansion /f "tokens=* usebackq" %%c in (results.txt) ( set result=%%c set result=!result:~83! rem writes trimmed line output file echo !result!>>"archivelist2.txt" ) findstr /v /l \ archivelist2.txt >> archivelist.txt findstr /v /l * androidlist2.txt >> androidlist.txt del results.txt del archivelist2.txt findstr /vixg:"archivelist.txt" androidlist.txt > discrepancies.txt /f "tokens=*" %%j in (discrepancies.txt) ( "c:\%userprofile%\adb\adb.exe" pull /sdcard/twrp/backups/0149bcaa1301701a/%%j/ twrp/backups/0149bcaa1301701a/%%j ) i'm aware code horrible kludge; i'm new @ this. i'm doing in first 2 lines pulling file lists text files, phone's android shell , 7zip archive respectively. after that, trim down both of them leave file names, , compare text files discrepancies.
the problem last step, reading discrepancies.txt , pulling relevant files phone. i've noticed if manually go discrepancies.txt , replace linebreaks (go end of each line, press delete, press enter), file parses correctly. how avoid or fix problem?
try this, might helpful:
for /f "tokens=*" %%j in (discrepancies.txt) ( /f "delims=" %%x in ("%%j") ( "c:\%userprofile%\adb\adb.exe" pull /sdcard/twrp/backups/0149bcaa1301701a/%%x/ twrp/backups/0149bcaa1301701a/%%x ))
Comments
Post a Comment