adb pull 换行符问题/冒号 报错终止
文件中有换行符,就会导致pull到windows时报错,导致中断(2024年5月30日测试,ftp也不行,ftp到windows里也会报错。solid explorer开ftp直接把文件卡空白了不知道为什么(知道了,好像是.隐藏目录不显示))
adb: error: cannot create 'F:\.......\0\MIUI\Gallery\cloud\.cache\.localthumbnailFile\L3N0b3JhZ2UvZW11bGF0ZWQvMC9EQ0lNL0NhbWVyYS9JTUdfMjAy
NDAzMTBfMTgzNjI5XzEuSEVJ
Q19WMV9MMTAyNzkwOA==
': No such file or directory
adb: error: failed to create directory 'F:\....\....\0\MIUI\debug_log\com.miui.voiceassist\dump\com.miui.voiceassist:voice_trigger\': Invalid argument
\012 ndk
\n static
尝试 删除/重命名 文件名中的换行符
https://stackoverflow.com/questions/1500204/how-do-i-remove-specific-characters-from-file-names-using-bash
for file in *; do echo "${file/\\n/}"; done
for file in *; do echo "${file/\012/}"; done
for file in *; do echo "${file/\n/}"; done
都不行
rename util-linux
不支持正则
cd /storage/self/primary/MIUI/Gallery/cloud/.cache/.localthumbnailFile
/data/local/tmp/rename.baseutils $'\n' '' *(每次只替换一个\n,所以如果有多个需要运行多次)
(2024年5月30日
cas:/storage/self/primary/MIUI/Gallery/cloud/.cache/.localthumbnailFile $ /data/local/tmp/rename.baseutils $'\n' '' *
/system/bin/sh: /data/local/tmp/rename.baseutils: Argument list too long(可能是文件太多的原因?)
find /storage/self/primary/MIUI/Gallery/cloud/.cache/.localthumbnailFile -name $'*\n*' -exec /data/local/tmp/rename.baseutils -v $'\n' '' '{}' \;
)
find /storage/emulated/0 -name *$'\n'*
find /storage/emulated/0 -name "*$'\n'*"(加上双引号就不行了,神奇,不知道为什么)
find /storage/emulated/0 -name $'*\n*'(这样可以)
find /storage/emulated/0 -name $'*\n*' -exec /data/local/tmp/rename.baseutils -v $'\n' '' '{}' \;(运行多次)
删除冒号:
for file in /storage/emulated/0/MIUI/debug_log/com.miui.voiceassist/dump/*; do mv -v "${file}" "${file/:/}"; done
(虽然报了个错,不知道为什么,但是实际替换成功了mv: bad '/storage/emulated/0/MIUI/debug_log/com.miui.voiceassist/dump/com.miui.voiceassist': Invalid argument)
for file in /storage/emulated/0/MIUI/debug_log/com.miui.voiceassist/dump/*; do echo "${file}"; done
find /storage/emulated/0 -name *:* -exec /data/local/tmp/rename.baseutils -v ':' '___' '{}' \;(Directory not empty 目录非空不能重命名)
替换为另外的字符再替换回来是个更好的方案
艹,百分号也不行(误解了,%可以,是路径超过260长度了)
find /storage/emulated/0 -name *%* -exec /data/local/tmp/rename.baseutils -v '%' '...' '{}' \;(重命名之后,会有一个find: xxx%xxx.log: No such file or directory因为已经重命名了,没法向下搜索了。因此只能替换最上边的目录,下边的子目录如果仍有%,需要多次替换)
经查询暂时无解,windows的adb大概并不支持LongPathsEnabled(即使在注册表中修改了也不行。windows上的git bash大概是支持LongPathss的,但没法在git bash里用adb啊)
只能先打包然后删掉原来长的或者非空无法重命名的文件了
cd xxx
tar --remove-files -c * > backup.tar(tar: unrecognized option: remove-files tar: Unknown option remove-files (see "tar --help") toybox busybox都不支持。。。)
tar -cvf ../backup.tar * && rm -R *
find . -type f -name "ACDC*" | while read -r file; do
mv "$file" "${file//ACDC/AC-DC}"
done
remote open failed: Permission denied
/storage/emulated/0/Android/data/com.miui.gallery/files/trashBin
不知道为啥有三四个目录 shell没权限 安卓12 miui13,上次安卓10miui12.5没遇到这个问题
不支持中文路径(中文文件名是支持的,文件夹名不支持)
搜了搜,有支持中文路径的修改版adb,但是就不能用我这个修改sync的adb了
https://issuetracker.google.com/issues/328095573
终于pull完了,比较校验一下
win上dir /s /b
Android上adb shell find /storage/emulated/0 | Out-File -FilePath find_only_$(Get-Date -Format 'yyyyMMdd_HHmmss').txt
然后替换掉前缀路径,正反斜杠替换一下
用beyond compare
格式-已排序
经过我人眼查验,没啥问题
--help
$ /data/local/tmp/rename.baseutils
rename.baseutils: not enough arguments
Try 'rename.baseutils --help' for more information.
1|c:/ $ /data/local/tmp/rename.baseutils --help
Usage:
rename.baseutils [options] <expression> <replacement> <file>...
Rename files.
Options:
-v, --verbose explain what is being done
-s, --symlink act on the target of symlinks
-n, --no-act do not make any changes
-a, --all replace all occurrences
-l, --last replace only the last occurrence
-o, --no-overwrite don't overwrite existing files
-i, --interactive prompt before overwrite
-h, --help display this help
-V, --version display version
For more details see rename(1).
adb exec-out "tar -c storage/emulated/0 | gzip" > sdcard_backup.tar.gz
powershell占内存(或许试试停一下自动记录)
cmd试了下 太慢,每秒2MB,不知道为什么,可能是gzip压缩耗时的原因?
杂项
find / -type d -path '/data/data*'
.\adb shell "/data/local/tmp/find.baseutils / -follow 2>&1 | xargs ls -dils 2>&1" | Out-File -FilePath ./find_root_chongdingxiang.txt
.\adb shell /data/local/tmp/tree.static -ughDpafl --device --inodes -L 50 | Out-File -FilePath mi10u_tree.static.txt
for file in *; do echo "${file}"; done
for file in *; do mv "${file}" "${file/000/}"; done
find /storage/self/primary/MIUI/Gallery/cloud/.cache/.localthumbnailFile -type f -exec rename 's/\n//' {} \;(这个是perl版的rename语法)
/data/local/tmp/rename.baseutils -n 's/\n//g' *
python adb-sync -R -t -n --dry-run /storage/emulated/0 F:\mi10ultra\adbpull
adb pull -a --sync /storage/emulated/0/Android/data/com.miui.gallery/files/gallery_disk_cache F:\mi10ultra\adbpull\0\Android\data\com.miui.gallery\files
ddradbp /storage/emulated/0/Android/data/com.miui.gallery/files/gallery_disk_cache/small_size F:\mi10ultra\adbpull\0\Android\data\com.miui.gallery\files\gallery_disk_cache
adb shell logcat -d | Out-File -FilePath "logcat_$(Get-Date -Format 'yyyyMMdd_HHmmss').txt"

浙公网安备 33010602011771号