Hello, On Sun, 25 Aug 2019, Carlos E. R. wrote:
On 25/08/2019 21.29, David Haller wrote: [..] That's a very good idea! I often forget this "mc" feature.
*hehe*
I just googled "sanitize filename for FAT", and found "npm", but there is no package. There may be others.
And mostly, you'd find the "node package manager" ;(
You could also add recode/iconv into the mix to convert filenames, but that should be handled by the iocharset of the fat-mount. ISTR, that ':' and '\' are the only chars disallowed on FAT (modulo the charset and up-/downcase collisions handled by the kerneldriver). Anyway, you can basically do lots instead of that simple 'tr'.
I use ":" often, but never "/" or "\".
You can not use '/' on *nix, for the same reason you can not use '\' on DOS as it's the dir-seperator... Anyway: as I hinted, I'm aware of only that '\/' conflict, the ':' and the mentionend case and charset issues, and the latter two should be handled by the FAT fs-driver of the kernel and its mountoptions. So I don't think you need to do anything more. And I think it's better to keep the case (FAT (at least FAT32) does preserve case IIRC, even though it folds case re. name-lookup etc.)... $ dd of=minifat ... $ mkfs.vfat -F32 minifat # mount -o loop minifat /mnt/loop; mkdir /mnt/loop/t # echo A > /mnt/loop/t/A # echo b > /mnt/loop/t/b # sync; umount /mnt/loop # mount -o loop minifat /mnt/loop # mount |grep /mnt/ minifat on /mnt/loop type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro) # cat /mnt/loop/t/* cat /mnt/loop/t/* A b # echo a > /mnt/loop/t/a # cat /mnt/loop/t/* a b # ls -l /mnt/loop/t/ total 2 -rwxr-xr-x 1 root root 2 Aug 25 22:41 A -rwxr-xr-x 1 root root 2 Aug 25 22:41 b So, FAT32/VFAT preserves the case, but folds it on access (or something to that effect). So, folding case to all upper/lower in the copy action is IMO not a good idea, better preserve the case. If collisions occur, the fs-driver will tell cp and that should tell you... Mh. That's one thing I'd have to test but you could do better: error handling... Not sure how that works in the mc-menu extension... *ARGH* It does not. Ok, 'cp -i' works as so far as dropping you to a subshell letting 'cp -i' ask if you want to overwrite the target file or not... So use: ==== the "F" at the start of each second line is the shortcut ==== + ! t t F cp-rename to FAT-compatible filenames to=$(echo "%f" | tr ':\\' '__') cp -i "%d/%f" "%D/$to" + t t F cp-rename to FAT-compatible filenames for i in %s ; do to=$(echo "$i" | tr ':\\' '__') cp -i "%d/$i" "%D/$to" done ==== else colliding target file will be overwritten as 'cp' is designed to do and 'a' will overwrite 'A'... Adding a 'test -e' for the dest into the scripts does not help, 'cp -i' is better as it drop you to the subshell. I'm out of ideas for better error handling today, but ISTR, there are ways... A whole different idea would be an extfs for fat but you'd have to manually use that via F9 -> [Left/Right] -> FAT fs or somesuch or via 'mc foo/vfat://' ;) But I'd just use the above with 'cp -i' and hope for few collisions ;) HTH, -dnh -- But, as we all know, "robust" and "stable" have different meanings in the computer industry. "robust": Probably won't fall over if a gnat farts nearby (unless the gnat is near a sensitive spot). "stable": no longer updated or supported by the manufacturer. -- Steve VanDevender -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org